开发者

multiple tcpip clients connected to same server?

I'm just starting out learning about TCP/IP.

I have written a simple TCP/IP server which listens on port 3000 and spawns a thread when a connection is received. That new thread sits and reads data. 开发者_运维问答My client application creates 100 connections to this server, and, using the tread pool, each connection gets a chance to send a unique message to the server.

The server doesn't respond to the message - it only prints it to the screen. So, the thing I am seeing is the listening thread in the server will sometimes read messages from several different clients in the same read.

I was under the impression that TCP would separate each message to allow each thread in the server to read the message sent to it, not to all others as well. Am I mistaken in my understanding, or do I have something else going on in my code?


You have something else in your code. Neither TCP or UDP will receive from multiple clients in the same read.

I would take a look at my buffer handling. Do post some server code regarding the reads.


Thanks. I figured it out. My client threads were executing much more often than I the read threads on the server. As a result, each read often contained the data from multiple writes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜