socket() bind() listen() accept() and probably a stupid ques

Hi,
I’m porting a client/server system from windows to qnx (windows client, qnx
server),
but am having difficulties getting the two to talk!

The server (qnx) sucessfully opens a socket, binds it to the nic on a
specified port,
listens() and blocks on accept();

the client (windows) opens a socket and tries to connect to the server, but
gets a
WSACONNREFUSED (refused connection) from the server… but the server
is listening and wants to connect

Now, as a newbie to qnx (and *nixy type things) my question is:

Do I have to specify the port I am using in one of the /etc files?

Thanks!

Kieran.

In article <8kqsv6$2bu$1@newsg1.svr.pol.co.uk>,
Kieran Tyrrell <kieran@faker.freeserve.co.uk> wrote:

Hi,
I’m porting a client/server system from windows to qnx (windows client, qnx
server),
but am having difficulties getting the two to talk!

The server (qnx) sucessfully opens a socket, binds it to the nic on a
specified port,
listens() and blocks on accept();

the client (windows) opens a socket and tries to connect to the server, but
gets a
WSACONNREFUSED (refused connection) from the server… but the server
is listening and wants to connect

Now, as a newbie to qnx (and *nixy type things) my question is:

Do I have to specify the port I am using in one of the /etc files?

No /etc files are needed.
Netstat -a should show your server port as listening.
Perhaps watching packets will tell you what is not working.


http://www.math.fsu.edu/~bellenot
bellenot math.fsu.edu
+1.850.644.7189 (4053fax)

Sorry - I was binding on the loopback ‘localhost’ interface, not the
ethernet one… it works now :wink:

“Kieran Tyrrell” <kieran@faker.freeserve.co.uk> wrote in message
news:8kqsv6$2bu$1@newsg1.svr.pol.co.uk

Hi,
I’m porting a client/server system from windows to qnx (windows client,
qnx
server),
but am having difficulties getting the two to talk!

The server (qnx) sucessfully opens a socket, binds it to the nic on a
specified port,
listens() and blocks on accept();

the client (windows) opens a socket and tries to connect to the server,
but
gets a
WSACONNREFUSED (refused connection) from the server… but the server
is listening and wants to connect

Now, as a newbie to qnx (and *nixy type things) my question is:

Do I have to specify the port I am using in one of the /etc files?

Thanks!

Kieran.

Kieran Tyrrell <kieran@faker.freeserve.co.uk> wrote:

Hi,
I’m porting a client/server system from windows to qnx (windows client, qnx
server),
but am having difficulties getting the two to talk!

The server (qnx) sucessfully opens a socket, binds it to the nic on a
specified port,
listens() and blocks on accept();

It actually doesn’t bind to a “nic”. It binds to a port. Depending
on how you bind, your machine config, and your network config its
possible that traffic will only come in over one NIC but thats not
necessarily true now nor even if its true now does it have to be true
over the runtime of the server.

the client (windows) opens a socket and tries to connect to the server, but
gets a
WSACONNREFUSED (refused connection) from the server… but the server
is listening and wants to connect

Now, as a newbie to qnx (and *nixy type things) my question is:

Do I have to specify the port I am using in one of the /etc files?

Probably not. There are two issues. One is defining the port of a
well defined service. Thats what /etc/services is for. Unless you
are looking up this service you are providing you don’t need to modify
/etc/services. The other is actually binding to the correct port.
I’d guess thats where your problem is.

The question I would ask is what port is the server bind()ng to
(‘netstat -an’ [1] is your friend) and what port is the windows machine
trying to connect to. I’d guess you probably didn’t ntohs() the port
before bind()ng to it and the server is bound to 0xCDAB while the
server is connecting to 0xABCD. How you figure out what the windows
side is doing the equivalent of a connect() to is unknown to me.

mph

[1] In fact ‘netstat’ is your friend in all unix TCP/IP work. Learn
its options. Twiddle its knobs. It’ll pay you back in multiples.

Previously, Kieran Tyrrell wrote in comp.os.qnx:

Hi,
I’m porting a client/server system from windows to qnx (windows client, qnx
server),
but am having difficulties getting the two to talk!

The server (qnx) sucessfully opens a socket, binds it to the nic on a
specified port,
listens() and blocks on accept();

the client (windows) opens a socket and tries to connect to the server, but
gets a
WSACONNREFUSED (refused connection) from the server… but the server
is listening and wants to connect

Now, as a newbie to qnx (and *nixy type things) my question is:

Do I have to specify the port I am using in one of the /etc files?

No.

Run netstat -a on your qnx machine, and on the windows machine. It’ll
tell you what sockets are bound to what ports/protocols.

You probably don’t need modify the /etc db files for protocols and services.

The netstat will give you a better idea what’s going on.

Sam


Sam Roberts (sam@cogent.ca), Cogent Real-Time Systems (www.cogent.ca)
“News is very popular among its readers.” - RFC 977 (NNTP)