0

Hi all:

I have successfully opened a socket to a server and trying to send some data vai the send() function. But what surprised me is: WSAGetLastError() returns nothing, which means the data has been sent to the server, however all the data (a string) will only be displayed at the moment I disconnect from the server.
p.s. I do not have access to the server codes, which has been written by someone else in Java.

Any help is deeply appreciated.

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by yuzhang
0

If send is successful I think it returns the number of bytes sent at that time. YOu can use that and compare with the number of data bytes you wanted to send to see if an error occured or not. GetLastError or WSAGetLastError is only used to get detailed error information, and not for error checking.

Anyway you are saying that the string is displayed only when you disconnect from the server. Displayed where? in the Client( that is your software ) or in the Server ( Java Software)? If it is the Server software, try appending a NULL, '\0' character to your string and see. Maybe the server is waiting for a NULL character as the data termination to display it. Since disconnecting sends a NULL character it is displaying it at that point.

0

Hi there:

Thank you for your fast and helpful reply. I managed to get this problem solved. The solution is to add "\r" at the end of the data string to be sent over to the server.

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.