Yanshof
Yanshof

Reputation: 9926

How to write simple TCP listener that will be able to send packages ?

I need to write simple TCP listener that will be able to listen TCP ( receive packages ) on one thread and in case i need to send some package i will be able to do it on some other thread

How can i do it ?

Upvotes: 2

Views: 943

Answers (2)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038850

You could use the TcpListener class. It has asynchronous versions of the methods such as BeginAcceptTcpClient which will in turn give you an instance of a TcpClient on which you could call GetStream to reach the underlying stream and from there on continue using the asynchronous versions on this stream to BeginRead and BeginWrite.

Upvotes: 2

JDunkerley
JDunkerley

Reputation: 12495

One simple project that might guide you: http://www.codeproject.com/KB/IP/TCPIPChat.aspx

Upvotes: 2

Related Questions