This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Socket programming with Cygwin


John Emmas wrote:

> 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).

The call fails because addr is junk, because the demo passed "localhost"
to inet_pton.  According to the docs, this function only takes IP
addresses.  If you change simple_client_main.cpp to use an IP address
instead of localhost the example works for me.  (It should really be
modified to do a hostname lookup.)  This example really isn't that great
in that it's apparently relying on some non-standard behavior of glibc's
inet_pton.

> 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

No, you don't need to install any service to use regular sockets.  The
plethora of network tools in the distro (e.g. apache, curl, openssh,
proftpd, lftp, wget, etc) that use sockets and that build without any
special modifications should be an indication that this should just
work.

Brian

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]