codefi
codefi

Reputation: 406

Copy TCP stream and retransmitt from two sockets

I need to create a server application that will take the TCP input from an Ethernet webcam and retransmit the packets to two different ports. The reason for this is that I want to connect to a webcam feed with two different programs (using one program locks the feed, making the connection unavailable for anyone else).

Can anyone please say if this is possible and perhaps provide some pseudo code. I am new to network programming and I am not sure on the best way of proceeding.

Upvotes: 0

Views: 521

Answers (1)

K893824
K893824

Reputation: 1319

Have a look at a basic TCP sockets tutorial such as this one.

In short, you can use TcpListener to detect incoming connections, TcpClient to store and interact with those methods server side, and make them client-side. You'd need a listener for the webcam connection, a client to hold that connection, and two more to route it's input into.


I've also create this gist this one (Thanks @jgauffin), that contains an working example program that does this, and two programs you can run to test it and see how it works. It's a bit too detailed for a SO answer, so I'll leave it there and let you examine it yourself.

Upvotes: 1

Related Questions