Article View: borland.public.cppbuilder.internet.socket
Article #3811Re: Creating sockets
From: Remy Lebeau (TeamB)
Date: Fri, 29 Apr 2005 22:55
Date: Fri, 29 Apr 2005 22:55
43 lines
2306 bytes
2306 bytes
"Jonathan Benedicto" <incorrect@no.server> wrote in message
news:4272a47c$1@newsgroups.borland.com...
> I restructured the server so that when a exception does
> get thrown, no memory is leaked.
See further below.
> addrlocal.sin_port = 52877;
You need to specify the port number in network byte order, such as by
calling htons():
addrlocal.sin_port = htons(52877);
Otherwise, you end up telling the server to listen on port 36302 instead,
which would explain why none of your clients can connect to your server.
> nRet = bind(g_sdListen, (sockaddr*) &addrlocal, sizeof(addrlocal));
> if( nRet == SOCKET_ERROR )
> throw Exception(myprintf("bind() failed: %d\n", WSAGetLastError()));
That exception leaks the socket allocated by WSASocket().
> nRet = listen(g_sdListen, 50);
> if( nRet == SOCKET_ERROR )
> throw Exception(myprintf("listen() failed: %d\n",
> WSAGetLastError()));
Likewise.
> nZero = 0;
> nRet = setsockopt(g_sdListen, SOL_SOCKET, SO_SNDBUF, (char *)&nZero,
> sizeof(nZero));
> if( nRet == SOCKET_ERROR )
> throw Exception(myprintf("setsockopt(SNDBUF) failed: %d\n",
> WSAGetLastError()));
Likewise.
Gambit
Technical Details
Message-ID:
<4272bad0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42717e9e$1@newsgroups.borland.com> <42718c45$1@newsgroups.borland.com> <4271b145$1@newsgroups.borland.com> <4271c6a8$1@newsgroups.borland.com> <4272519f$1@newsgroups.borland.com> <42727b69$1@newsgroups.borland.com> <4272a47c$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,890efe40447445cf X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <42717e9e$1@newsgroups.borland.com> <42718c45$1@newsgroups.borland.com> <4271b145$1@newsgroups.borland.com> <4271c6a8$1@newsgroups.borland.com> <4272519f$1@newsgroups.borland.com> <42727b69$1@newsgroups.borland.com> <4272a47c$1@newsgroups.borland.com> Subject: Re: Creating sockets Date: Fri, 29 Apr 2005 15:55:35 -0700 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <4272bad0$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1114815184 68.69.17.41 (29 Apr 2005 15:53:04 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail