Socket Program Problem!!!
-
Hi, I am doing a very basic thing of sending data to a server and getting the reply back. For which first I have to send in a Login request and get authenticated, once authenticated, I have to send the actual data. The problem I am facing is when I send the data, it embeds some funny characters before the actual text, which is causing the problem. Upon further investigation, it was found that if I send the data without the login, it gets to the server correctly. Is there some kind of REFRESH!!! for the second time when the data is sent so that it has correct values? [CODE] ========================================= for login authentication: e = sendto(sd,"8888\n",89,0,(struct sockaddr *)&saServer,sizeof(saServer)); For sending Data: e = sendto(sd,"888808M5359846Test+Value\n"); ========================================== [CODE] The second sendto, does not send the data correctly. Is there some refresh after we do the first sendto? Kindly Help!!! Best Regards, John:((
-
Hi, I am doing a very basic thing of sending data to a server and getting the reply back. For which first I have to send in a Login request and get authenticated, once authenticated, I have to send the actual data. The problem I am facing is when I send the data, it embeds some funny characters before the actual text, which is causing the problem. Upon further investigation, it was found that if I send the data without the login, it gets to the server correctly. Is there some kind of REFRESH!!! for the second time when the data is sent so that it has correct values? [CODE] ========================================= for login authentication: e = sendto(sd,"8888\n",89,0,(struct sockaddr *)&saServer,sizeof(saServer)); For sending Data: e = sendto(sd,"888808M5359846Test+Value\n"); ========================================== [CODE] The second sendto, does not send the data correctly. Is there some refresh after we do the first sendto? Kindly Help!!! Best Regards, John:((
From MSDN-doc I get that the 3rd parameter of
::sendto()
isint len
. Are you setting this one correctly to the length of the data you want to transmit? And: do you get an error-return in your variablee
? -- "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert Kaminski -
From MSDN-doc I get that the 3rd parameter of
::sendto()
isint len
. Are you setting this one correctly to the length of the data you want to transmit? And: do you get an error-return in your variablee
? -- "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert KaminskiHi, yes the return variable is '0' which is correct. Thanks, John
-
Hi, yes the return variable is '0' which is correct. Thanks, John
So, having 0 bytes transfered is correct? I don't think so! Something is rotten here, and I am of no help, 'cause I never used sockets. Sorry! But it seems you HAVE TO read the MSDN about this. "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert Kaminski
-
Hi, I am doing a very basic thing of sending data to a server and getting the reply back. For which first I have to send in a Login request and get authenticated, once authenticated, I have to send the actual data. The problem I am facing is when I send the data, it embeds some funny characters before the actual text, which is causing the problem. Upon further investigation, it was found that if I send the data without the login, it gets to the server correctly. Is there some kind of REFRESH!!! for the second time when the data is sent so that it has correct values? [CODE] ========================================= for login authentication: e = sendto(sd,"8888\n",89,0,(struct sockaddr *)&saServer,sizeof(saServer)); For sending Data: e = sendto(sd,"888808M5359846Test+Value\n"); ========================================== [CODE] The second sendto, does not send the data correctly. Is there some refresh after we do the first sendto? Kindly Help!!! Best Regards, John:((
Maybe you should empty the socket buffer before restarting to use
sendto
again. How are you authenticating it (from the sender point of vue) ? Does the sender got something from the reciever (confirmation message ?) so that he is allowed to send data ? If yes, this could have been sent back if the buffer was not emptied. I experienced that a couple of months ago. ~RaGE(); -
Maybe you should empty the socket buffer before restarting to use
sendto
again. How are you authenticating it (from the sender point of vue) ? Does the sender got something from the reciever (confirmation message ?) so that he is allowed to send data ? If yes, this could have been sent back if the buffer was not emptied. I experienced that a couple of months ago. ~RaGE();Hi, How do I empty the socket buffer? If you can help me out with it, I guess it would solve my problem!!! Kindly Help, John
-
Hi, yes the return variable is '0' which is correct. Thanks, John
John Bosko wrote: yes the return variable is '0' which is correct. which is _not_ correct. Try and give the length of the data you want to send as third parameter of the
sendto
. I think that this is really a buffer problem. When you send your data without preceding it by the login request, the buffer is empty (and not full with the loggin request stuff), so IMO that's why there is no problem in that case. ~RaGE(); -
Hi, How do I empty the socket buffer? If you can help me out with it, I guess it would solve my problem!!! Kindly Help, John
John Bosko wrote: How do I empty the socket buffer? I was just looking for it, but i did not find anything, and i cannot remember myself :( Sorry .. I stiil think this should not happen if you receive the same amount of byte that you send, so be careful to the length parameter in
sendto
. Sorry i cannot help more. ~RaGE(); -
So, having 0 bytes transfered is correct? I don't think so! Something is rotten here, and I am of no help, 'cause I never used sockets. Sorry! But it seems you HAVE TO read the MSDN about this. "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert Kaminski
Oops!! sorry I gave you the return code '0' which means success. yes, there is a return confirmation which I am getting. But I am not selecting the entire return confirmation, just taking in first 40 bytes. Thanks, John