Socket communication problem

S

Sandy Dunlop

Hi,
I'm new here, and fairly new to Python. I have been playing around with
Python and started having a look at socket IO. I have written a script
that communicates over a network to a server which is written in C.
While trying to get this working, I have been running into a problem
where the Python client appears to hang when it should be receiving data
back from the server.

After a few successful exchanges of data, the server sends 3605 bytes to
the client, which the client receives. The server then sends 2 bytes to
the client, and the client doesn't get them. A client program written in
C# does not have this problem.

I have narrowed the problem down as far as I can, and have two small
scripts, client and server, and a data file they read from to know what
they should be sending and receiving. The problem can be replicated
using them within a few milliseconds of running them.

At first, I thought this may be caused by Nagel's algorithm, so I
disabled it explicitly using:

s.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)

This made no difference.
Can anyone point out what I'm doing wrong here?

You can get the scripts and the 7K data file here:
http://www.sorn.net/~sandyd/python/problem/

Or all together in a zip file here:
http://www.sorn.net/~sandyd/python/problem.zip


Thanks in advance,
Sandy
 
S

Sandy Dunlop

Sandy said:
Hi,
I'm new here, and fairly new to Python. I have been playing around with
Python and started having a look at socket IO. I have written a script
that communicates over a network to a server which is written in C.
While trying to get this working, I have been running into a problem
where the Python client appears to hang when it should be receiving data
back from the server.


I forgot to add, I'm using Python 2.5.1 on OS X, and have also tried my
program under Python 2.5.1 on Solaris 9.


Cheers,
Sandy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top