Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Datagram sockets, sequence of methods to call

Datagram sockets, sequence of methods to call

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vcLearner
    wrote on last edited by
    #1

    How to use datagram sockets? ie what are the methods to call, to create a server or listening socket nd client socket. 1. create socket using create method,I creted 2 sockets. But I dint know,whether two should be on same port or not. Next what I have to do? CAll the connect method? Anyone pl help me to use SOCK_DGRAM option ie the sequence od opertaions for datagrams. Thanku :confused: :confused: Be creative Once your mind is streched by a new idea, it will never regain its original dimension

    A L 2 Replies Last reply
    0
    • V vcLearner

      How to use datagram sockets? ie what are the methods to call, to create a server or listening socket nd client socket. 1. create socket using create method,I creted 2 sockets. But I dint know,whether two should be on same port or not. Next what I have to do? CAll the connect method? Anyone pl help me to use SOCK_DGRAM option ie the sequence od opertaions for datagrams. Thanku :confused: :confused: Be creative Once your mind is streched by a new idea, it will never regain its original dimension

      A Offline
      A Offline
      Antonio Mazzeo
      wrote on last edited by
      #2

      Datagram sockets don't have a method to connect... use sendto and recvfrom for send/receive data with this socket Antonio

      1 Reply Last reply
      0
      • V vcLearner

        How to use datagram sockets? ie what are the methods to call, to create a server or listening socket nd client socket. 1. create socket using create method,I creted 2 sockets. But I dint know,whether two should be on same port or not. Next what I have to do? CAll the connect method? Anyone pl help me to use SOCK_DGRAM option ie the sequence od opertaions for datagrams. Thanku :confused: :confused: Be creative Once your mind is streched by a new idea, it will never regain its original dimension

        L Offline
        L Offline
        lucy 0
        wrote on last edited by
        #3

        As mrcod said, there's no connect() or accept() for datagram sockets, since they are connectionless socket. Usually what I do is: the one send data: socket(); get receiver's address (fill in struct sockaddr_in with the receiver's ip address and port number); sendto(); the one receive data: socket(); bind(); set it to a non-blocking socket if you'd like to recvfrom();

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups