C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 09-15-2007, 10:32 PM   #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
Rot_Helmut is offline   Reply With Quote
Old 09-15-2007, 11:17 PM   #2
Registered User
 
Join Date: Oct 2001
Posts: 2,110
os/api etc?

example code?
robwhit is offline   Reply With Quote
Old 09-15-2007, 11:30 PM   #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
Rot_Helmut is offline   Reply With Quote
Old 09-15-2007, 11:31 PM   #4
Registered User
 
Join Date: Sep 2007
Posts: 3
oops

Visual c++ 2005
Windows XP
Windsock 2.0
Rot_Helmut is offline   Reply With Quote
Old 09-16-2007, 01:42 PM   #5
Registered User
 
Join Date: Oct 2001
Posts: 2,110
please make it compilable and indent your code.
robwhit is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 06:04 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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