Jump to content
  • Advertisement
Sign in to follow this  
mackscynox

port listen and data send

This topic is 4834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi everyone i want to ask a question about data sending and receiving on tcp network. i want to write simple 2 programs that sends and receives datas over network and a simply: //listener program listen always if message received process it send back answer by coming socket //sender program send data by sockets listen for answer My problem is in sender , when the sender sends message data by using sockets (TcpClient class in .NET) then should i close the socket (TcpClient) i used in sending data and open a new listening socket for receiving the answer? Also i think that , if i close the sending socket and open a new socket for receiving the answer from listener program i may miss the listener program's answer because of timing of the processes. i work in C#.net and use TcpListener , TcpClient , Socket classes in .NET I know my problem is a simple one but i couldnot find an exact solution to my proeblem, also i doubt my knowledge over sockets/network programming in .NET :) thanx

Share this post


Link to post
Share on other sites
Advertisement
Well you would firstly run a server using TCP as a stream connection. Run a client in the same mode and then you can simply call send() or recv()on whichever end you like whenever you like.

ace

Share this post


Link to post
Share on other sites
TCP sockets are bidirectional. Thus, after sending the request, you should keep the socket open and wait for the response. Each end can send at the same time, if they want to, and the other end will get it while the sockets are still open.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!