Skip to contentSkip to conversation

TCP port numbers

DISCUSSION ych43 3 participants 3 messages Nov 1, 2004

lore
Share & tools
lore

ych43

author
#0 lore raw

Hi,
I got one question about unix socket functions. I have two machines (called A
and B). I use A to telnet B, get the root password of B. Is there any unix socket function I can use to get the port number of A on B. Obviously, the port number of B is 23. I want to use a socket function implemented on B to get the port number of A because a TCP connection is established between them.
I greatly appreciate it if you help me. Thank you in advance. Xue

#1 lore raw
Quoted 5 lines

Hi,
I got one question about unix socket functions. I have two machines (called A and B). I use A to telnet B, get the root password of B. Is there any unix socket function I can use to get the port number of A on B. Obviously, the

The 'struct sockaddr_in' you're filling in on B's site with the call with accept() also fills in the port number.

Quoted 4 lines

port number of B is 23. I want to use a socket function implemented on B to get the port number of A because a TCP connection is established between them.
I greatly appreciate it if you help me. Thank you in advance. Xue

Jan Engelhardt

Signature · 2 lines
Gesellschaft für Wissenschaftliche Datenverarbeitung
Am Fassberg, 37077 Göttingen, www.gwdg.de
#2 lore raw
In reply to ych43
Quoted 6 lines · ych43 wrote:

Hi,
I got one question about unix socket functions. I have two machines (called A
and B). I use A to telnet B, get the root password of B. Is there any unix socket function I can use to get the port number of A on B. Obviously, the port number of B is 23. I want to use a socket function implemented on B to get the port number of A because a TCP connection is established between them.
I greatly appreciate it if you help me. Thank you in advance.
Xue

I think getpeername is the library call you are looking for HTH
Neil

Quoted 5 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 8 lines
/***************************************************
 *Neil Horman
 *Software Engineer
 *Red Hat, Inc.
 *[email protected]
 *gpg keyid: 1024D / 0x92A74FA1
 *http://pgp.mit.edu
 ***************************************************/