Linux socket programming

T

The D0ct0r

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
 
A

AnonMail2005

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
 
T

The D0ct0r

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!").
 
K

kasthurirangan.balaji

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.
 
R

Rafael Anschau

" 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
 
R

Rafael Anschau

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
 
T

The D0ct0r

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top