Thread: UDP socket programming

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    3

    UDP socket programming

    Hi all,

    I've just learnt socket programming using winsock. Currently i have a server that can receive datagrams from a client. I would like to add 2 more servers to this network, and at the same time, these 3 servers can send dgrams to one another.

    May I know how can this be achieved?

    Many thanks in advance.

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    68
    Is this a trick question? If you have a server and client setup already, then you know how to do it.

    What is the question ?

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    3
    I'm sorry, I should have been more specific.

    The 3 servers are to send and receive packets without going through the client. In another words, on top of being able to receive data from the client, each server has to send data to the other two servers without using the first client.

    May I know if this is possible?

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    check out the winsock commands

    sendto

    receivefrom

    a server is only a server because it's designated as such. In the end it's all just packets and IPs.

    Also... are you sure you're not confusing the terms server and client?
    Last edited by CommonTater; 09-28-2010 at 05:32 AM.

  5. #5
    Registered User
    Join Date
    Sep 2010
    Posts
    3
    hey common tater, thanks for ur reply . I have some directions now.

    The servers will listen to the client and perform some task, am I right?

    Currently I have gotten the servers to perform the task as sent by client. Now, I need an additional feature to the servers, that is being able to send data to other servers. I've been searching the Internet for the answer. It seems to be that there's something called the "UDP broadcast". Is this the answer to my question?

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by becheras View Post
    hey common tater, thanks for ur reply . I have some directions now.

    The servers will listen to the client and perform some task, am I right?

    Currently I have gotten the servers to perform the task as sent by client. Now, I need an additional feature to the servers, that is being able to send data to other servers. I've been searching the Internet for the answer. It seems to be that there's something called the "UDP broadcast". Is this the answer to my question?
    Yes, servers are listeners, waiting for something to do.
    Clients are talkers, issuing instructions to servers.

    But, in a great many applications that line is blurry at best. For example a client requests a list of updated transactions. The server sends the list, the client processes them and sends them back... which is which? It's very often a distinction without a difference.

    The UDP broadcast supported by most routers etc. is not intended to handle regular data flow. It's more of an announce port where clients can advertise for servers. It's a bit more complex than that, but for now...

    There is no magical line between clients and servers. Server to server communication is no different than client to server. If server A wants to talk to server B all it has to do is send the information to server B's IP address and port... It really is just that simple. The same is true for client to client communications... happens all the time.

    It's just a matter of writing the programs to make it happen.
    Last edited by CommonTater; 09-28-2010 at 11:40 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Use one socket to send and receive message (using UDP)
    By tanya9x in forum C++ Programming
    Replies: 11
    Last Post: 02-28-2010, 05:58 AM
  2. Receive a TCP message on a UDP socket?
    By Yarin in forum C++ Programming
    Replies: 5
    Last Post: 09-05-2009, 12:21 AM
  3. Can I bind a UDP socket to a port, but send to any other port?
    By trillianjedi in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-25-2009, 04:27 PM
  4. read/write through udp socket
    By xErath in forum Networking/Device Communication
    Replies: 3
    Last Post: 05-22-2005, 05:43 PM
  5. problem with UDP WSAAsyncSelect socket, no callback message received???
    By hanhao in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-29-2004, 11:59 AM