Thread: Getting Ip from socket.

  1. #31
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Is there anyway the clients could possibly send to much for the server to handle at once?
    Data will automatically be broken up into smaller chunks when you send them. The actual size of these packets will be based upon the senders MTU value, but it should be smaller than 1600 bytes for sure. If you are worried about losing data due to all the clients sending a bunch of information at once, and your socket buffer filling up, then I can put your mind to rest. If a packet gets lost somehow, a client will automatically resend the data. This is all worked into the TCP protocol, so you dont have to worry about programming any of it yourself. Now this is of course assuming you are using TCP packets, and not UDP. If you are using UDP, then there is a possibility of losing packets (especially under a high server load).

    or block, when they try to call send().
    If TCP is the protocol being used, then they would block until the packet has been successfully sent. If necessary, the send method automatically resends the packet if it doesnt make it to it's destination. If the protocol is UDP, the function would return immediately, and you would never know for sure whether or not the packet got to its destination.

    I am using the Select statement, it's just that i thought maybe a thread for each client would be a better idea.
    I agree. A thread for each client would be a better idea.

  2. #32
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>then they would block until the packet has been successfully sent.
    And if you want to prevent blocking, you can either use asynchronous winsock (it will return an error of WSAEWOULDBLOCK if you can't send right away), or use select() with the writefds parameter filled in.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #33
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    Thanks everybody, this thread has been a great help to me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting 32 bit binary IP to decimal IP (vice-versa)
    By Mankthetank19 in forum C Programming
    Replies: 15
    Last Post: 12-28-2009, 07:17 PM
  2. Extracting WAN IP out of a SOCKET
    By apsync in forum Windows Programming
    Replies: 13
    Last Post: 10-04-2008, 02:38 PM
  3. Problem while constructing IP packet and sending using socket() system call
    By cavestine in forum Networking/Device Communication
    Replies: 10
    Last Post: 10-15-2007, 05:49 AM
  4. IP without connecting to external socket
    By Hunter2 in forum Networking/Device Communication
    Replies: 5
    Last Post: 08-26-2003, 07:50 AM