CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Socket

  1. #1
    Join Date
    Aug 2002
    Posts
    193

    Socket

    is someone know here how it possible to know if a port is in use or not

    imagine you have your serveur who want toopen multiple listener socket

    exple

    while(kljfdlkljkdf)

    if this port is ok listenat this port
    else
    port++
    if you think that you c'ant that's means that you can !! : think about it all your life if you understand there you can

  2. #2
    Join Date
    Apr 2003
    Location
    Morelia, Mexico
    Posts
    40
    You could try to open each port, on ports already in use the listen function should return an error code.

    Other way would be to manually attempt connections to 127.0.0.1 (localhost) at port X, if you are able to connect to it then it is listening, close the connection and proceed to the next port.
    int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
    o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}

  3. #3
    Join Date
    Sep 2002
    Posts
    1,747
    I believe the IP Helper API has functions that can help you here. In particular, GetTcpTable can enumerate open TCP ports on the various addresses mapped by the machine, and there is a similar UDP function. Additionally, full source code is available here for a program that shows how to use the IP Helper API to get all sorts of useful information. I hope this is helpful!
    */*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

    "It's hard to believe in something you don't understand." -- the sidhi X-files episode

    galathaea: prankster, fablist, magician, liar

  4. #4
    Join Date
    Aug 2002
    Posts
    193
    thx for the tow solutions
    but i think i prefer try a listning in this case.
    there is a socket error
    it's not too long to execute
    if you think that you c'ant that's means that you can !! : think about it all your life if you understand there you can

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