my code:
SOCKET sock = INVALID_SOCKET;
sock = socket(PF_INET, SOCK_STREAM, 0);
RETAILMSG(1, (L"~~~~~~~~sock[%d]\n", sock ) );
if (INVALID_SOCKET == sock)
{
strShow.Format(TEXT("socket err[%d]"), WSAGetLastError());
AfxMessageBox(strShow);
return;
}
SOCKADDR_IN addr;
ZeroMemory(&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(25);
addr.sin_addr.s_addr = inet_addr("192.168.1.2");
if (connect(sock, (PSOCKADDR)&addr, sizeof(addr)) == SOCKET_ERROR)
{
strShow.Format(TEXT("connect error[%d]"), WSAGetLastError());
closesocket(sock);
return;
}
RETAILMSG(1, (L"~~~~~~~~closesocket[%d]\n", sock ) );
closesocket(sock);
--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/wince-vc/200906/1
On the other hand, I've never actually seen this happen in any version of
Windows CE that I've used, so I'd think seriously first that there was
something wrong with my code. Although I don't think this is related, the
first parameter to socket() in your case should be AF_INET, not PF_INET.
Paul T.
"fantasy1215 via PocketPCJunkies.com" <u50650@uwe> wrote in message
news:97f9b23744181@uwe...
Paul G. Tobey [eMVP] wrote:
>closesocket() is not an instantaneous operation. Negotiation with the other
>end of the socket occurs in the normal case. If you're actually telling us
>everything, my guess would be that you're calling socket() again before the
>other socket is actually broken, but after the socket number, 1, is marked
>as unused in the socket table. By the time you get to connect(), the socket
>is truly broken with the server and so the connect operation is invalid.
>
>On the other hand, I've never actually seen this happen in any version of
>Windows CE that I've used, so I'd think seriously first that there was
>something wrong with my code. Although I don't think this is related, the
>first parameter to socket() in your case should be AF_INET, not PF_INET.
>
>Paul T.
>
>>I write client code to connect to my server. socket then connect.
>> When first time socket return, I print to see the SOCKET handle returned
>[quoted text clipped - 29 lines]
>> RETAILMSG(1, (L"~~~~~~~~closesocket[%d]\n", sock ) );
>> closesocket(sock);
--
Message posted via http://www.pocketpcjunkies.com
Paul T.
"fantasy1215 via PocketPCJunkies.com" <u50650@uwe> wrote in message
news:9801c6eed7b49@uwe...