473,385 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Linux socket programming

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
Jun 27 '08 #1
6 3663
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
Jun 27 '08 #2
On Sat, 10 May 2008 09:06:51 -0700, An**********@gmail.com 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!").
Jun 27 '08 #3
On May 10, 11:07 am, The D0ct0r <thed0c...@xs4all.nlwrote:
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.
Jun 27 '08 #4
" 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
Jun 27 '08 #5
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
Jun 27 '08 #6
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.
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tom Jones | last post by:
I need to access databases on both win2k and Linux systems but I have to set up the DSNs under program control ... no uses using GUIs ... Has anyone done this? if so can we discuss it either in...
0
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the fastest and cheapest way to get up and going with PHP on...
3
by: Douwe | last post by:
I'm trying to write a piece of C code that has two threads: The first thread waits for a socket connection. The second thread is in a continues cycle waiting for an period of time (lets say 500 ms)...
3
by: Robert Smith | last post by:
As you can tell by my code that I will post I am obviously new with linux socket programming so to be to hard on me :) When I run my little program I get this error: Server: got connection from...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
8
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi all, I am new to .net technologies. ASP.NET supports socket programming like send/receive in c or c++? I am developing web-site application in asp.net and code behind is Visual C#. In...
1
by: Murali | last post by:
Greetings from Pivot Systems, Inc.!!! Pivot Systems, Inc. established in 1997 is a global software services company, California corporation with several customers in the Silicon Valley,...
3
by: sniper1000 | last post by:
what are basic difference in C socket and network programming between linux and windows? and what is the difference between liberarries? Tanks
5
by: ganeshp | last post by:
Hi , In Java using socket programming is it possible to have a server program on windows that services a client program on linux? I tried the code in the below given link:...
3
by: TsanChung | last post by:
I want to make a java TCP socket client to communicate with a TCP server socket on linux. Are there some sample C unix server and java client socket programs available? The Richard Stevens'...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.