Thread: Need help with winsock2

  1. #1
    Never Exist Hermitsky's Avatar
    Join Date
    Jul 2004
    Posts
    149

    Question Need help with winsock2

    i am doing a server/client program with winsock2. once a client starts, it will connect to server and send some info. after server got these info,the connection will be closed,and the server will waiting for another client.

    now i wanna make sure that, once the server-socket accept a connection,this connection won't last more than 10 seconds. if one connection lasts more than 10 seconds,then the server-socket should close the connection automatically. is there anyway to set that time limit? any suggestion would be greatly appreciated.......

    blow me ... ...

  2. #2
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    you can set read and write timeouts, but if you want to limit the connection time to 10 seconds, you will need to do something like spawn a separate thread for each connection, have it sleep 10 seconds and then close the socket if it hasn't been closed yet.

  3. #3
    Never Exist Hermitsky's Avatar
    Join Date
    Jul 2004
    Posts
    149
    Thanks, rockytriton.

    one more question: how to set the read time-out ?

    blow me ... ...

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268

  5. #5
    Never Exist Hermitsky's Avatar
    Join Date
    Jul 2004
    Posts
    149
    thanks guys .....

    blow me ... ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cross Network communication using Winsock2?
    By dp_76 in forum Networking/Device Communication
    Replies: 6
    Last Post: 05-20-2005, 07:05 AM
  2. connecting to ftp server (winsock2)
    By commissar in forum C++ Programming
    Replies: 1
    Last Post: 03-03-2005, 10:22 AM
  3. Linker errors on Winsock2 functions
    By ShadowMetis in forum C++ Programming
    Replies: 2
    Last Post: 11-20-2004, 11:19 PM
  4. cant use winsock2 in dev-c++
    By datainjector in forum Tech Board
    Replies: 2
    Last Post: 08-30-2003, 03:55 PM
  5. Strange MSVC winsock2 compile error
    By LuckY in forum Windows Programming
    Replies: 3
    Last Post: 06-28-2003, 08:18 AM