Click to See Complete Forum and Search --> : Fd_oob?
connie_fox
December 1st, 2004, 09:35 PM
Hello,
Could anyone tell me what does FD_OOB mean? When TCP client application quit, my TCP server application in VC++ receives this event.
Thanks and best regards,
connie
connie_fox
December 1st, 2004, 09:41 PM
Forgot to say NetworkEvents.lNetworkEvents=2. Is it FD_OOB?
connie
Mathew Joy
December 2nd, 2004, 12:50 PM
No. FD_OOB is 4, and it means Out Of Band Data. Generaly, you shouldn't be worring about OOB. You get it only if you have marked it as one(to say the least).
Mathew Joy
December 2nd, 2004, 11:56 PM
Forgot to mention. 2 is FD_WRITE.
connie_fox
December 3rd, 2004, 02:05 AM
Thank you very much, Mathew Joy.
My TCP server application continously receives FD_CONNECT, as I described in another thread (WSAEnumNetworkEvents) , how is that? Do you have any idea? Could you please give me a piece of advice?
connie
Mathew Joy
December 3rd, 2004, 10:04 AM
Are you trying for a connect? Are you sure you are talking about FD_CONNECT and not FD_WRITE? Because above you say you are getting NetworkEvents.lNetworkEvents=2. And did you check the return value of the WSAEnumNetworkEvent()? If it is non-zero value you have to get the error number thru a call to WSAGetLastError().
connie_fox
December 6th, 2004, 02:48 AM
Hello,
Let me make it clear.
My application is a TCP server. I want to be notified when TCP client connects, sends or disconnects. I used WSAWaitForMultipleEvents() in my application.
I tested again and again and found that while(b_ServerStop!=true)
{
......
}
in my TCP server application sometimes goes into infinite loop. Please find it at the end of my message.
I tested with my code and a sample VC++ TCP client application. I kept my TCP server application running. The client would do connect(), send(), shutdown(), step by step, then I closes this client application. Then I restarted the client.
I found that my application worked well for the first time the client connected,but when I restarted the client and the client connect(), my application continuously receive network event after client connect(),NetworkEvents.lNetworkEvents=8, then goes into infinite loop. I checked the return value of WSAEnumNetworkEvents(), when I found it goes to -1, I used WSAGetLastError(), and the return value is 10038, WSAENOTSOCK.
How is that? Why does the same TCP server code and the client code work well for the first time and not the second time?
if ((ret!=WSA_WAIT_FAILED) && (ret!=WSA_WAIT_TIMEOUT))
{
Index=ret-WSA_WAIT_EVENT_0;
for (int i=Index;i<EventTotal;i++)
{
Index=WSAWaitForMultipleEvents(1,&EventArray[i],TRUE,1000,FALSE);
int b=WSAGetLastError();
if ((Index!=WSA_WAIT_FAILED) && (Index!=WSA_WAIT_TIMEOUT))
{
Index=i;
b=WSAEnumNetworkEvents(SockArray[Index],EventArray[Index],&NetworkEvents);
b=WSAGetLastError();
Had a quick look at your code and is wondering why you call WSAWaitForMultipleEvents twice?
The second call makes the lookup in SockArray to always hit index = 0... A bug... Haven't looked further down in the code.
connie_fox
December 6th, 2004, 06:55 PM
Hello,
Thanks for your reply.
I commented out the second WSAWaitForMultipleEvents(), but it still did not work. It was the same.
The problem is when the TCP client sent out the connect() for the second time, my TCP server continously receive network event, that is the first WSAWaitForMultipleEvents() always receives event.
By the way, what is CODE tag?
Thanks again.
connie
j0nas
December 7th, 2004, 03:36 PM
The codes tags makes source lists to be displayed nicely formatted in the posts. Ex:
int main()
{
puts("Nicely formatted piece of code...");
return 0;
}Put CODE within [ ] to begin the code section.
Put /CODE within [ ] to end the code section.
Back to your problem:
Try add some debug tracing etc... And post a new version of your code (within CODE tags), and I'll promise you to have a second look at it.
connie_fox
December 7th, 2004, 07:35 PM
Hi,
Sorry, I did not quite catch up with you on how to make code tags.
if ((ret!=WSA_WAIT_FAILED) && (ret!=WSA_WAIT_TIMEOUT))
{
Index=ret-WSA_WAIT_EVENT_0;
for (int i=Index;i<EventTotal;i++)
{
Index=WSAWaitForMultipleEvents(1,&EventArray[i],TRUE,1000,FALSE);
int b=WSAGetLastError();
if ((Index!=WSA_WAIT_FAILED) && (Index!=WSA_WAIT_TIMEOUT))
{
Index=i;
b=WSAEnumNetworkEvents(SockArray[Index],EventArray [Index],&NetworkEvents);
b=WSAGetLastError();
if(NetworkEvents.lNetworkEvents==FD_ACCEPT )
{
if (pdlg_sevr->SocketCheck(server,SC_READ))
{
WSAEVENT newclientevent;
newclientevent=WSACreateEvent();