open a port

Asked by Magnus Grander

Hi !

How can i be sure that a port is open. i want to open port 1001 in ubuntu. Ihave a small c++
program that communicates throught that one. If it is needed i can change that too.
I reach the socket on the other end and i also see that the device is sending back.
But in my program i never seems to recive any packages...
I know this is question is very much related to c++. But i just need to be sure that the error
is mine not in the configuration of ubuntu...

thanks;

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Ralph Janke
Solved:
Last query:
Last reply:
Revision history for this message
Ralph Janke (txwikinger) said :
#1

Thanks for the question.

As long as you don't have any firewall configured and running, all ports should be available, they don't need to be opened particularly. Your description looks like you open a connection to the device and the device responds. If so, you just need to open a tcp connection in your c++ program and read the particular socket.

This is all I can say with this information given. Feel free to give some more information.

I hope this helps.

Revision history for this message
Magnus Grander (maggrand) said :
#2

Thanks Ralph.

But i have heard that all ports in Ubuntu is closed by default ?

And in this case its the same socket that i read and write from.
When i list the current open/used ports...i can't see any 1001 either ?!
I use "ClientSocket" from the net. So i send binary data to the device.
I see the packages in tcpdump. So all this confuses me a bit..

Revision history for this message
Best Ralph Janke (txwikinger) said :
#3

Magnus,

the ports are "closed" if they are not used, meaning ubuntu linux will not respond if there is no application claiming the port. However, in lieu of a firewall running there is nothing preventing the application claiming a port.

If you see the packages, then there does not seem to be a problem with the port. DO you also see the packages that are sent by the device in responds. If so, the request package clear went out and a response came back.

Maybe you don't pick up the messages send back to your port in your C++ program. I don't know you program, but usually you have some kind of loop waiting for the responds and reading it from the socket.

Do you have any error messages that you program creates?

I hope this helps.

Revision history for this message
Magnus Grander (maggrand) said :
#4

Well atleast now i know that the error is in my C++ program..yehaaa...not in ubuntu.
and no it generates no errors. The program just seems to 'lock up' in a waiting mode.
It looks like it don't see the comming packages or something.

thanks for all the help thought

Revision history for this message
Magnus Grander (maggrand) said :
#5

Thanks Ralph Janke, that solved my question.