Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here





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:

while (true)

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...

RE: CSocket::Send


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.

RE: CSocket::Send

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...

RE: CSocket::Send

You're welcome.

RE: CSocket::Send

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!

RE: CSocket::Send

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close