I am implementing in C on Windows : A channel of communi开发者_StackOverflowcation between a sender and a receiver.
The channel has to receive packages from sender, transfer them to the receiver and then back from receiver to the sender.
The Channel connects to sender (maybe multiple senders) on port 1 and connects to the receiver on port 2
What is a good way of doing it? Both ports 1 and 2 have to be able to send and receive. how to I use select in such situation?
I want to use a single threaded environment.
Not sure either about your exact question, but indeed TCP sockets are bidirectional. You can put the same file descriptor in both the read and write (and except) FD_SETs in the same select call.
The question isn't very clear but TCP connections are bi directional - and there's no need to open a separate socket for each direction.
精彩评论