Socket programming with Cygwin
Wed Dec 3 09:52:00 GMT 2008
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).
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
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
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
More information about the Cygwin