TCP/IP stops blocking... Help pls...

This is a discussion on TCP/IP stops blocking... Help pls... within the Networking/Device Communication forums, part of the General Programming Boards category; I have a problem when I send a block of data over the page limit, the problem is the blocking ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    TCP/IP stops blocking... Help pls...

    I have a problem when I send a block of data over the page limit, the problem is the blocking somehow doesnt work anymore even when i explicitly use ioctlsocket to turn it on, I am not sure why it only does this after a large buffer is sent and recieved... I have them both in a loop to make sure the data is all sent and all recieved, that part works fine as i have steped through it all... its just that the server goes and checks to see if it can send or recieve and does it even though it should be blocked until the client sends...

    Any help on the subject would be most appreciated.
    thanks

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    os/api etc?

    example code?

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    my code

    ////////////////// --- server side ---- ////////////////////////

    Code:
    if( xnet.HasValidConnection() )
    {
         if( xnet.IsReadAvailable() )
         {
              xnet.RecieveMsg( buff );
              if( xnet.IsWriteAvailable() )
    	ServerHandleMessage( &xnet ); 
         }
    }
    
    
    //////////////////  ---   client side  ---- ////////////////////////
    if( xnet.IsWriteAvailable() )
    {
         xnet.xmsg->buffer_size = 0;
         xnet.SendMsg( GETVIDEOBUFFER, 0 );
    }
    
    if( xnet.IsReadAvailable() )
    {
        xnet.RecieveMsg( xscr.mini_pixel_buffer );
        xnet.ClientHandleMsg();
    }
    
    /////////////////functions
    
    
    bool IsReadAvailable()
    {
    		 
    fd_set read_able;
    int can_read = 0;
    read_able.fd_count = 0;
    FD_SET( client_sock, &read_able);
    
    can_read = select( 0, &read_able, 0, 0, 0 );
    if( can_read == 1 )
         return true;
    else
         return false;
    }
    
    bool IsWriteAvailable()
    {
    fd_set write_able;
    int can_write = 0;
    write_able.fd_count = 0;
    FD_SET( client_sock, &write_able);
    
    can_write = select( 0, 0, &write_able, 0, 0 );
    if( can_write == 1 )
         return true;
    else
         return false;
    }
    
    bool SendMsg( UINT xmsg_num, void *buffer )
    {
    int recieved = 0;
    
    xmsg->xmsg_num = xmsg_num;
    xmsg->validity_id = VALID_MSG;
    
    send( client_sock, (char*)xmsg, sizeof( XMSG ), 0 );
    	
    do
    {
    recieved += sendto( client_sock, (char*)buffer + recieved, xmsg->buffer_size -                                 recieved, 0, 0, 0 );
    int err = WSAGetLastError();
    if( err == WSAENOTCONN )
         has_connection = 0;
    		
    }
    while( recieved < xmsg->buffer_size );
    }
    
    
    
    bool RecieveMsg( void *buffer )
    {
    
    int recieved = 0;
    
    recv( client_sock, (char*)xmsg, sizeof( XMSG ), 0 );
    if( xmsg->validity_id != VALID_MSG)
         return false;
    
    do
    {
    recieved += recvfrom( client_sock, (char*)buffer + recieved, xmsg->buffer_size -                                    recieved, 0, 0, 0 ); 
    int err = WSAGetLastError();
    if( err == WSAENOTCONN )
         has_connection = 0;
    
    }
    while( recieved < xmsg->buffer_size );
    
    return true;
    }
    
    
    
    void ServerHandleMessage()
    {
    msg->buffer_size = 400 * 320 - 1;
    net_class->SendMsg( SENTVIDEOBUFFER, xscr.buffer );
    }
    
    void ClientHandleMessage()
    {
    //dostuff
    }
    thanks

  4. #4
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    oops

    Visual c++ 2005
    Windows XP
    Windsock 2.0

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    please make it compilable and indent your code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to initialize a non blocking socket using only winsock library
    By *DEAD* in forum Networking/Device Communication
    Replies: 4
    Last Post: 01-18-2008, 06:03 AM
  2. Compiler Stops Compiling
    By tyler4588 in forum C++ Programming
    Replies: 8
    Last Post: 08-02-2003, 10:20 PM
  3. Basic port scanner code .. pls help ???
    By intruder in forum C Programming
    Replies: 18
    Last Post: 03-13-2003, 07:47 AM
  4. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 09:46 AM
  5. pls help me!!
    By hanseler in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2001, 07:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21