X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <493665A0.6F1DE647@dessent.net> Date: Wed, 03 Dec 2008 02:55:28 -0800 From: Brian Dessent MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Socket programming with Cygwin References: <003201c9552c$a57b1a00$4001a8c0 AT mycomputer> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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/