|
-
May 4th, 2012, 09:55 AM
#1
Client writing to itself???
It's been several years since I've done any socket programming, so when I started messing with something recently I became very confused by some affects occurring that I thought should have worked. Here's the scenario.
I created a TCP client with two threads. Correct me if I'm wrong, but I believe socket connections internally have two buffers (an input buffer and an output buffer). So I created a thread to read from the socket while the main line of execution could simultaneously write to the socket.
I then wrote a simple server to test the client. When the server sent a message to the client, the client's read thread worked just fine. The client's write thread then sent a message back to the server, however, instead of the server getting this message the client's read thread actually ending up retrieving the message off the socket. The server also came off the socket but there was nothing to read since the client already “stole” the data. So, essentially the client ended up sending data to itself.
How is this possible? Any thoughts would be greatly appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|