hi guys

im trying to make a little peer-2-peer camera program using pygame,PIL and VideoCapture.

what im doing is sending pictures in a row to make a video.

my problem is that after my first picture (which appears on the client's screen!) i get an error (in the client program):
Traceback (most recent call last):
File "C:\Users\CHRIS\Desktop\CAMERA\CLIENT.py", line 36, in <module>
image = pygame.image.frombuffer(data,(90,60),"RGB")
ValueError: Buffer length does not equal format and resolution size


my code looks like this:

Server:
import socket
from VideoCapture import *
from PIL import *

server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('',5000))
server_socket.listen(5)
camera = Device()
image = camera.getImage()
print "NEW CONNECTION!"


while 1:
client_socket, address = server_socket.accept()
image = camera.getImage()
print "I got a connection from ", address

image = camera.getImage().convert("RGB")

image = image.resize((90,60))

data = image.tostring()

client_socket.sendall(data)



Client:
import socket
import pygame
import Image
import PIL
import time

timer = 20

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((socket.gethostname(),5000))

pygame.init()
screen = pygame.display.set_mode((640,480))
pygame.display.set_caption('Remote Webcam Viewer')
font = pygame.font.SysFont("Arial",14)
clock = pygame.time.Clock()

data = client_socket.recv(409600000)
image = pygame.image.frombuffer(data,(90,60),"RGB")
image = pygame.transform.scale(image,(640, 480),)
pygame.display.flip()

while 1:
output = image
while timer>0:
screen.blit(output,(0,0))
pygame.display.flip()
timer=timer-1

client_socket.close()
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((socket.gethostname(),5000))
data = client_socket.recv(409600000)
image = pygame.image.frombuffer(data,(90,60),"RGB")
image = pygame.transform.scale(image,(640, 480),)
timer=30
pygame.display.flip()



somebody help, please?


Thankes,
kernelOD