Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

Join Tek-Tips
*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.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

cpfc (Programmer) (OP)
30 Nov 03 22:12
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:


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...
alcyone (Programmer)
1 Dec 03 4:32
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.
cpfc (Programmer) (OP)
1 Dec 03 13:50
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...
alcyone (Programmer)
1 Dec 03 14:42
You're welcome.
Laopang (Programmer)
2 Dec 03 3:25
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!

cpfc (Programmer) (OP)
2 Dec 03 23:56
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.

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