Socket programming with Cygwin

John Emmas johne53@tiscali.co.uk
Wed Dec 3 09:52:00 GMT 2008


Hi guys,

For the past few weeks I've been struggling to compile a program that uses
sockets.  Actually, the program compiles and builds okay but the client can
never connect to the server.

This morning I found this simple example that implements client/server
socket comms in just a few modules (probably no more than 200 lines of
code, in total).

http://tldp.org/LDP/LG/issue74/tougher.html

I thought this would be a great way to test the process but even this simple
sample won't work under Cygwin (although it builds and works fine under
Linux).

In every case, the programs fail when the client attempts to connect to the
server.  This would be a typical line:-

status = ::connect ( m_sock, ( sockaddr * ) &addr, sizeof ( addr ) );

'status' receives -1 and if I check the error it's invariably something like
"Connection refused" (assume for the sake of argument that the supplied
parameters are valid because the same programs work fine under Linux).

Do I need to enable something in Cygwin for sockets to work?  e.g. should
I have previously run a service using cygrunsrv?  I'm running out of things
to try and there seems to be very little that could go wrong.  I'd be
grateful for any suggestions.  Thanks

John 


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list