g****n 发帖数: 18 | 1 我有一个client和server编程上的问题,在程序中有两个client
socket,比如说socket_1和socket_2在client中,同样在server一边有两个对应的socket
,server_socket_1和server_socket_2,
现在要求socket_1和server_socket_1通信,用single
thread,socket_2和server_socket_2通信,用multithread,做不同的事情,问题是怎么
样让这两个通信并行工作(这两个通信不是synchronized) ?
非常感谢! | m**i 发帖数: 89 | 2 Well, you need to understand what server socket is first.
【在 g****n 的大作中提到】 : 我有一个client和server编程上的问题,在程序中有两个client : socket,比如说socket_1和socket_2在client中,同样在server一边有两个对应的socket : ,server_socket_1和server_socket_2, : 现在要求socket_1和server_socket_1通信,用single : thread,socket_2和server_socket_2通信,用multithread,做不同的事情,问题是怎么 : 样让这两个通信并行工作(这两个通信不是synchronized) ? : 非常感谢!
| c****r 发帖数: 185 | 3 Well, in server side, there should be a daemon thread listening to a
pre-defined port
with a server socket. When the server socket accepts, it will return a normal
socket.
Then the daemon uses another thread to handle the socket.
two
socket,比如说socket_1和socket_2在client中,同样在server一边有两个对应的socket
是
【在 g****n 的大作中提到】 : 我有一个client和server编程上的问题,在程序中有两个client : socket,比如说socket_1和socket_2在client中,同样在server一边有两个对应的socket : ,server_socket_1和server_socket_2, : 现在要求socket_1和server_socket_1通信,用single : thread,socket_2和server_socket_2通信,用multithread,做不同的事情,问题是怎么 : 样让这两个通信并行工作(这两个通信不是synchronized) ? : 非常感谢!
| g****n 发帖数: 18 | 4 Thanks, do you have a simple example that I can take a look of and get the
idea more clearly?
Thanks again!
normal
socket,比如说socket_1和socket_2在client中,同样在server一边有两个对应的socket
题
【在 c****r 的大作中提到】 : Well, in server side, there should be a daemon thread listening to a : pre-defined port : with a server socket. When the server socket accepts, it will return a normal : socket. : Then the daemon uses another thread to handle the socket. : : two : socket,比如说socket_1和socket_2在client中,同样在server一边有两个对应的socket : 是
|
|