Linux socket programming

Discussion in 'C++' started by The D0ct0r, May 10, 2008.

  1. The D0ct0r

    The D0ct0r Guest

    Hi People,

    I am working on a tcp client/server, using this tutorial: http://tldp.org/
    LDP/LG/issue74/tougher.html
    Everything works fine, as long as I connect to my own machine (localhost)
    When I try to connect to a remote server (A hired virtual machine in
    Berlin) the client gives the following error message: "Exception was
    caught: Could not bind to port."
    But, the most weird thing, I can connect to the server using telnet. That
    works fine, so it isn't a firewall problem.
    Does anyone knows what I am doing wrong?

    The D0ct0r
     
    The D0ct0r, May 10, 2008
    #1
    1. Advertising

  2. The D0ct0r

    Guest

    > I am working on a tcp client/server, using this tutorial:http://tldp.org/
    > LDP/LG/issue74/tougher.html
    > Everything works fine, as long as I connect to my own machine (localhost)
    > When I try to connect to a remote server (A hired virtual machine in
    > Berlin) the client gives the following error message: "Exception was
    > caught: Could not bind to port."
    > But, the most weird thing, I can connect to the server using telnet. That
    > works fine, so it isn't a firewall problem.
    > Does anyone knows what I am doing wrong?


    This is OT but...

    I could be wrong but I do believe telnet (and other *nix networking
    utilities)
    use fixed port numbers. The telnet port could be enabled but the port
    you are
    trying to connect may not be. So it could be a firewall issue.

    Try connecting to another machine to eliminate the any potential
    firewall issue.
    Also, check out asio in boost for socket programming.

    HTH
     
    , May 10, 2008
    #2
    1. Advertising

  3. The D0ct0r

    The D0ct0r Guest

    On Sat, 10 May 2008 09:06:51 -0700, wrote:

    >> I am working on a tcp client/server, using this
    >> tutorial:http://tldp.org/ LDP/LG/issue74/tougher.html
    >> Everything works fine, as long as I connect to my own machine
    >> (localhost) When I try to connect to a remote server (A hired virtual
    >> machine in Berlin) the client gives the following error message:
    >> "Exception was caught: Could not bind to port."
    >> But, the most weird thing, I can connect to the server using telnet.
    >> That works fine, so it isn't a firewall problem. Does anyone knows what
    >> I am doing wrong?

    >
    > This is OT but...
    >
    > I could be wrong but I do believe telnet (and other *nix networking
    > utilities)
    > use fixed port numbers. The telnet port could be enabled but the port
    > you are
    > trying to connect may not be. So it could be a firewall issue.
    >
    > Try connecting to another machine to eliminate the any potential
    > firewall issue.
    > Also, check out asio in boost for socket programming.
    >
    > HTH


    I don't think so, because I gave telnet as argument the host and the port
    number. And a connection was established, because I sent something to the
    server, the server responded, and sent a message back. (By hand) (I
    believe it was something like "Hello, client!").
     
    The D0ct0r, May 10, 2008
    #3
  4. The D0ct0r

    Guest

    On May 10, 11:07 am, The D0ct0r <> wrote:
    > Hi People,
    >
    > I am working on a tcp client/server, using this tutorial:http://tldp.org/
    > LDP/LG/issue74/tougher.html
    > Everything works fine, as long as I connect to my own machine (localhost)
    > When I try to connect to a remote server (A hired virtual machine in
    > Berlin) the client gives the following error message: "Exception was
    > caught: Could not bind to port."
    > But, the most weird thing, I can connect to the server using telnet. That
    > works fine, so it isn't a firewall problem.
    > Does anyone knows what I am doing wrong?
    >
    > The D0ct0r


    Though this is OT here, i believe you needn't use bind system call.
    Since you are connecting to another server,now you will be a client.
    socket and connect should be the system calls you need to use(check
    exact call/syntax for your platform). By the way, my guess is that if
    you had caught the errno, it should be 49.

    Alternately, you may use comp.unix.programmer or so and also ensure
    you do not multipost.

    Thanks,
    Balaji.
     
    , May 10, 2008
    #4
  5. " When I try to connect to a remote server (A hired virtual machine in
    Berlin) the client gives the following error message: "Exception was
    caught: Could not bind to port." "

    Can you tell exactly what message the server-side gives ? Like many
    engineering problems,
    it seems to have something to do not with problem in A or in B, but in
    the way A and B
    interface(or rather communicate, in this case).

    []´s

    Rafael
     
    Rafael Anschau, May 10, 2008
    #5
  6. In addition, the server you have in your own machine seems to be a
    different one than the server you are trying to connect(they speak
    different languages, or at least dialects). Either get the message
    errors from the machine in Berlin, or set the exact server on your
    machine and see what message errors it gives.

    Rafael
     
    Rafael Anschau, May 10, 2008
    #6
  7. The D0ct0r

    The D0ct0r Guest

    On Sat, 10 May 2008 11:32:34 -0700, Rafael Anschau wrote:

    > In addition, the server you have in your own machine seems to be a
    > different one than the server you are trying to connect(they speak
    > different languages, or at least dialects). Either get the message
    > errors from the machine in Berlin, or set the exact server on your
    > machine and see what message errors it gives.
    >
    > Rafael


    Thanks for the help, but i solved it already. I used for the address to
    connect to the domain name of my server. After that the function inet_pton
    () tried to solve where to connect to. But inet_pton could only handle ip-
    addresses, but not hostnames, so it tried to connect to the localhost.
    Anyway, thanks for the help.
     
    The D0ct0r, May 15, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    1
    Views:
    4,855
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    971
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    552
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    666
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    719
Loading...

Share This Page