CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2018
    Posts
    158

    UDP socket , client side

    In UDP communication when I send a packet from client I execute the socket() system call but I didn't understand if It's necessary to follow the bind()one too.

    client side

    Case A:

    socket(...)
    bind(...)
    sendto(...)


    Case B:
    socket(...)
    sendto(...)

    It's right A or B or both cases ?
    Peraphs if I omit bind() the O.S. automatically executes It ?


    Bind links socket to ip address+port, so according my opinion this task should be execute from each client too, because clients in TCP/UDP communication use IP+port. What do you think ?

    Thanks
    Last edited by zio_mangrovia; April 26th, 2023 at 10:58 PM.

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,382

    Re: UDP socket , client side

    AFAIK, bind() is used on the server side, not on the client one, For the client there are the following steps to create a socket and communicate: Winsock Client Application
    Victor Nijegorodov

  3. #3
    Join Date
    May 2018
    Posts
    158

    Re: UDP socket , client side

    Quote Originally Posted by VictorN View Post
    AFAIK, bind() is used on the server side, not on the client one, For the client there are the following steps to create a socket and communicate
    Perhaps on client side, O.S. associates IP+Port to socket because client socket end has to get IP with an ephemeral port to send data by nuetwork, if you use bind() you will specify exactly these data (if you have multiple interface or specific port over 1024) which will bring forward from O.S.

Tags for this Thread

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