🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #3804

Re: Creating sockets

#3804
From: Jonathan Benedicto
Date: Fri, 29 Apr 2005 15:24
51 lines
2618 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:4271c6a8$1@newsgroups.borland.com...
>
> In the code you showed earlier, you are not waiting for the 
> FD_ACCEPT
> notification or calling accept().  Clients cannot fully connect to 
> the
> server without that.

All that code I posted is inside a function called CreateListenSocket. 
And here is how I call that function, and what comes after it.

CreateListenSocket();

while( true )
{
    sdAccept = WSAAccept(g_sdListen, NULL, NULL, NULL, 0);
    if( sdAccept == SOCKET_ERROR )
        throw Exception(myprintf("WSAAccept() failed: %d\n", 
WSAGetLastError()));

    lpPerSocketContext = UpdateCompletionPort(sdAccept, ClientIoWrite, 
true);
    if( lpPerSocketContext == NULL )
        throw Exception("UpdateCompletionPort returned NULL.");

    if( g_bEndServer )
        break;

    AnsiString Response = "100 VoIS Server Ready.";
    WSABUF buffSend;

    dwFlags = 0;
    buffSend.buf = Response.c_str();
    buffSend.len = Response.Length();
    nRet = WSASend(sdAccept, &buffSend, 1, &dwRecvNumBytes, dwFlags,
    &(lpPerSocketContext->pIOContext->Overlapped), NULL);
    if( nRet == SOCKET_ERROR && (ERROR_IO_PENDING != 
WSAGetLastError()) )
    {
        CloseClient(lpPerSocketContext, false);
        throw Exception(myprintf("WSASend() failed: %d\n", 
WSAGetLastError()));
    }
    else if( g_bVerbose )
    {
        mycprintf("Socket sent greeting\n");
    }
}

Jonathan 
Technical Details
Message-ID: <4272519f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42717e9e$1@newsgroups.borland.com> <42718c45$1@newsgroups.borland.com> <4271b145$1@newsgroups.borland.com> <4271c6a8$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: "Jonathan Benedicto" <incorrect@no.server>
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>
Subject: Re: Creating sockets
Date: Fri, 29 Apr 2005 11:24:15 -0400
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 69.158.104.124
Message-ID: <4272519f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1114788255 69.158.104.124 (29 Apr 2005 08:24:15 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail