multiple socket connection
-
Hi all, Can somebody help me on how to create multiple connection to different server using ip/port at the same time and receive data. I have a program in C# but it's only working for 1 connection. Please help me or redirect me for a tutorial on multiple socket programming in C#. I'm new to this thing.
-
Hi all, Can somebody help me on how to create multiple connection to different server using ip/port at the same time and receive data. I have a program in C# but it's only working for 1 connection. Please help me or redirect me for a tutorial on multiple socket programming in C#. I'm new to this thing.
Multithreading will do the trick. Just open a each TcpListener or Socket(udp) connection in a seperate thread.
-
Hi all, Can somebody help me on how to create multiple connection to different server using ip/port at the same time and receive data. I have a program in C# but it's only working for 1 connection. Please help me or redirect me for a tutorial on multiple socket programming in C#. I'm new to this thing.
You've shown that you have the code to connect from one machine to another. Just duplicate it. Nothing says that you can have only one socket open at a time so it's fine to do something like this:
open Socket A
open Socket B
. . .
read something from A
. . .
write the data to B
. . .
close A
close Byou don't even need to close the sockets for each operation. You can leave them open for the lifetime of the process if you need to instead of opening them and closing them each time that you need them. Unfortunately I don't have any links to tutorials on multiple socket programming; i doubt that any really exist. There's no real difference between using one socket and using multiple sockets except that in the former you see things like
Socket
and in the latter you'll see things likeList ( Socket )
.:badger: