Python <-> C via sockets

Rene Pijlman reply.in.the.newsgroup at my.address.is.invalid
Wed Sep 24 09:54:06 EDT 2003


Nick Keighley:
>    sin.sin_port = PORT;

"serv_addr.sin_port = htons(portno);

The second field of serv_addr is unsigned short sin_port , which contain
the port number. However, instead of simply copying the port number to
this field, it is necessary to convert this to network byte order using
the function htons() which converts a port number in host byte order to a
port number in network byte order."
http://www.cs.rpi.edu/courses/sysprog/sockets/sock.html

-- 
René Pijlman




More information about the Python-list mailing list