CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2007
    Posts
    43

    tcpip/winsock -- how long to keep connection open?

    Hi, guys. I'm a n00b with tcpip/winsock, and I'm curious about performance in a simple real-time game server/client.

    What I'm doing:
    -server takes control data from client (maybe 4-6 bytes) and process character positions, collisions etc.
    -server sends a small packet of data (maybe 20-40 bytes) very often (ideally 60 times/sec for "real time" control but about 10 times/sec would be okay)
    -client does nothing but update screen characters using coordinates provided by the server, and take in input to send back to the server.


    My question:
    -Should I keep a persistent connection open for each client, and send byte-length codes each time I send data? or
    -Can I close/reopen the connections 10-60 times / sec?

    -Also, can anyone offer other advice, pointers or links with regard to a very simple protocol that they've used?

  2. #2
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,158

    Re: tcpip/winsock -- how long to keep connection open?

    Even though this question should have gone into the networking section, here are my thoughts:
    from what you describe, I would use UDP as the underlying protocol. UDP is "connection less", so you don't have the overhead of TCP, especially when sending small packets every few milliseconds. Once the client has registered at the server, you can use one connection for send/receive, no need to close the connection after each send (that would be a bad idea anyway).

    The simplest protocol would be to use UDP and just send your data. UDP packets are always received completely, so once you receive a packet, you can process it immediately.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured