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. One Socket for listening and sending/receiving, simultaneously?

One Socket for listening and sending/receiving, simultaneously?

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminjsonquestion
4 Posts 2 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.
  • A Offline
    A Offline
    Aidman
    wrote on last edited by
    #1

    Hi, Is it possible to use the same Windows socket for listening (for new connections) and at the same time exchanging data (using the sendto() and recvfrom() functions)? Or must I have two separate sockets, and if so must the separate sockets also be bound to separate network ports? Just for the info, I am using WinSock 2 API functions. High thanks in advance :) Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

    J 1 Reply Last reply
    0
    • A Aidman

      Hi, Is it possible to use the same Windows socket for listening (for new connections) and at the same time exchanging data (using the sendto() and recvfrom() functions)? Or must I have two separate sockets, and if so must the separate sockets also be bound to separate network ports? Just for the info, I am using WinSock 2 API functions. High thanks in advance :) Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

      J Offline
      J Offline
      Johnny
      wrote on last edited by
      #2

      A socket is bi-directional, so you can read and write on it.

      J 1 Reply Last reply
      0
      • J Johnny

        A socket is bi-directional, so you can read and write on it.

        J Offline
        J Offline
        Johnny
        wrote on last edited by
        #3

        Sorry, didn't read your message correctly. When you 'accept' a connection on a listening socket then Windows will automatically create you a seperate socket with which you communicate to that client. You don't need to worry what port this is on as its all handled by the 'accept' call.

        A 1 Reply Last reply
        0
        • J Johnny

          Sorry, didn't read your message correctly. When you 'accept' a connection on a listening socket then Windows will automatically create you a seperate socket with which you communicate to that client. You don't need to worry what port this is on as its all handled by the 'accept' call.

          A Offline
          A Offline
          Aidman
          wrote on last edited by
          #4

          You must have misunderstood me (could be partly my fault sorry), I meant if it is possible to listen for incomming connections (not to accept them) and simultaneously communicate (sending/receiving) with a non-connected client? For ex: * socket S is created. * bind S to network address with specific port. * Create thread T. * set S to listen for incoming connections * meanwhile on thread T, socket S is sending and receiving messages. Is the above situation possible? :confused: Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

          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