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 ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.