0

I am writing client in c++ (socket programming) but the server has two options to send to client request and also server can send data on specific port(lets say port ZZ). I want the client listening on port ZZ non-blocking. How can I do it? Would select() command will help me? or is there any other technique to implement this. Thanks

Aqeel Raza
  • 1,729
  • 4
  • 15
  • 24

2 Answers2

1

You can use either the non blocking mode or you use a very small block time (like one millisecond).

To active non blocking mode you have to configure your socket alike.

See Beejs Guide to socket Programming to learn how to do it.

Quonux
  • 2,975
  • 1
  • 24
  • 32
  • Thanks for answer. How can I put small block time? – Aqeel Raza Apr 06 '13 at 21:19
  • see for example here http://stackoverflow.com/questions/4181784/how-to-set-socket-timeout-in-c-when-making-multiple-connections (linux), on windows you need to check out the winapi socket functions (winsock) – Quonux Apr 06 '13 at 21:22
0

Maybe use multithread is a better choice. You can use recive reponse tin the main thread and listen the port ZZ in another thread.