Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSocket::Send

Status
Not open for further replies.

cpfc

Programmer
Aug 4, 2003
23
GB
Hi.
I have a client socket connected to server socket.
If server keeps using the CSocket::Send function to send client data, for example using the following code:

Code:
while (true)
{
	Client->Send("a");
}

After a while (not straight away), if the client socket isn't calling CSocket::Receive to receive the data being sent to it, in the above code the entire application freezes on the line Client->Send("a") until client does eventually call the Receive function.
With the server app froze no more clients can connect to server, or receive data from other clients who are currently connected.

Hope my problem makes sence, and I'll be greatful for any replies, thanks in advance...
 
Hi,

I'm not known with CSocket, but in C when you connect to a socket you can define the socket as blocking or non-blocking. In non-blocking mode, a Send function always returns, even if it isn't able to send. I think that's what you want. I'm sure you can do this with CSocket as well.
 
Thank you for reply...
I looked into non-blocking sockets and found due to bad design from microsoft CSocket is unable to do non-blocking sockets. However I changed CSocket to CAsyncSocket which CSocket derived from and now my application works perfectly with non-blocking sockets...
Thanks again appricated...
 
Try to use CAsyncSocket, it is an asynchonism socket.

And, why do you use a "while" loop? It always send the data , and there is no opportunity to receive data.

No taboo from the fat man!
 
I am using CAsyncSocket now, the while loop was to demonstrate my problem, I'm really callling Send within a timer. All works fine now, thanks for reply all the same Laopang.
By the way, there don't seem to be much diffrence between CAsyncSocket and CSocket except the older class works better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top