Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Number of sockets needed?  (Read 2645 times)

0 Members and 1 Guest are viewing this topic.

Azaral

  • Full Member
  • ***
  • Posts: 110
    • View Profile
Number of sockets needed?
« on: November 07, 2012, 02:30:27 am »
I'm trying to set up a server-client relationship in which the server can accept a number of clients. Do I need a socket for each client or can I service them all on one? Using UDP sockets btw.

I'm very very new to network programming. Any advice is appreciated.
« Last Edit: November 07, 2012, 02:38:03 am by Azaral »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Number of sockets needed?
« Reply #1 on: November 07, 2012, 08:52:03 am »
UDP sockets are not connected, you can use a single socket for everyone.
Laurent Gomila - SFML developer

Azaral

  • Full Member
  • ***
  • Posts: 110
    • View Profile
Re: Number of sockets needed?
« Reply #2 on: November 07, 2012, 01:51:43 pm »
Would there be an advantage to using more than one? If a packet is sent to a UDP socket, but the socket already accepted a packet and it hasn't been cleared out of the socket, will that second packet be lost or will it wait in a queue fashion or something?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Number of sockets needed?
« Reply #3 on: November 07, 2012, 01:55:53 pm »
There are independant send/receive buffers, so the only thing that might happen is that you send or receive too much data on the same socket and overflow one of the buffers.
Laurent Gomila - SFML developer

Azaral

  • Full Member
  • ***
  • Posts: 110
    • View Profile
Re: Number of sockets needed?
« Reply #4 on: November 07, 2012, 06:18:36 pm »
OK. Thanks for your answers!