Professional Web Applications Themes

1 Port, listening and connecting, how to? - UNIX Programming

Hi, I am implementing a client using TCP/IP and Berkeley sockets. I would like to have one port to connect to the server AND listen to incoming connections. I don't know how to do this. Would I have to use threads, forks? Is there a way to do this without threads, forks? Thank you so much for your help. Marcia Hon...

  1. #1

    Default 1 Port, listening and connecting, how to?

    Hi,

    I am implementing a client using TCP/IP and Berkeley sockets. I would like
    to have one port to connect to the server AND listen to incoming
    connections. I don't know how to do this.

    Would I have to use threads, forks? Is there a way to do this without
    threads, forks?

    Thank you so much for your help.

    Marcia Hon


    Marcia Guest

  2. #2

    Default Re: 1 Port, listening and connecting, how to?

    In article
    <cCXVb.28902$bloor.is.net.cable.rogers.com>,
    "Marcia Hon" <com> wrote:
     

    What do you mean by this? You want the outgoing connections to use the
    same local port number as the incoming connections? Why do you think
    this is necessary? Unless there's some special constraint, you should
    normally let the OS choose an ephemeral port for outgoing connections,
    and only use a well-known port for listening for incoming connections.
     

    Threads and forking have nothing to do with the selection of ports. Now
    I think you're asking something totally different, like how to manage
    multiple sockets. You can have a separate thread or process manage each
    connection if you want, or you can do it all in a single thread by using
    select() or poll() to wait for something to happen on multiple sockets.

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    Barry Guest

  3. #3

    Default Re: 1 Port, listening and connecting, how to?



    "Cameron Kerr" <net.nz> wrote in message
    news:<maxnet.co.nz>...
     
     [/ref]
     [/ref]
     [/ref]
     [/ref]
     [/ref]
     
     
     
     
     
     
     
     
     
     
     
     


    Marcia Guest

  4. #4

    Default Re: 1 Port, listening and connecting, how to?

    Marcia Hon wrote:
     

    See setsockopt(SO_REUSEADDR). You may have _one_ listening socket and _some_
    outgout connections on the same port.
    Threads are not related to this question at all.

    BTW: What is this good for?
    Lorinczy Guest

Similar Threads

  1. Can you see what port(s) FMS is listening on?
    By sparky1962 in forum Macromedia Flash Flashcom
    Replies: 0
    Last Post: October 5th, 09:07 PM
  2. Replies: 1
    Last Post: July 8th, 08:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139