Python <-> C via sockets

Nick Keighley nick.keighley at marconi.com
Wed Sep 24 10:28:25 EDT 2003


Eric Brunel <eric.brunel at pragmadev.N0SP4M.com> wrote in message news:<bkroq8$8ud$1 at news-reader1.wanadoo.fr>...
> Nick Keighley wrote:
> > I'm probably missing something rather obvious, but is there a known 
> > problem with getting a Python based socket program to communicate with
> > a C based socket program? A simple echo server written in Python
> > (the example from Python in a Nutshell actually) will happily talk
> > to a Python based client. If a C based client is substitued the connection
> > is refused (or so the C client reports). The C client will talk to
> > a C server.
> 
> Communications between C and Python via sockets definetly work: we do that 
> every  day (no kidding ;-)
> 
> Can you post an example of your code?

by the time you read this the posted code may have appeared.
A call to htons() (convert unsigned short to network byte order) 
was ommitted on the C side.

this line:-
     sin.sin_port = PORT;

should read:-
    sin.sin_port = htons(PORT);


thanks!

-- 
Nick Keighley




More information about the Python-list mailing list