|
-
July 20th, 2002, 05:56 PM
#1
Getting Socket Port Numbers
I have an application that I am converting from Java, and one of the things that the application must do is to read the port number for a socket (client or server). I have been all through the documentation for Socket and TcpListener, but I cannot find a property or method that will give me the port number. The specific Java code I am trying to implement in C# is:
if ( null != this.client_Socket )
{
iPort = this.client_Socket.getPort();
}
else if ( null != this.server_Socket )
{
iPort = this.server_Socket.getLocalPort();
}
Does anyone know how I can get the port numbers?
-
July 21st, 2002, 10:20 AM
#2
Something like this(not tested):
Code:
IPEndPoint endp =(IPEndpoint)this.clientSocket.LocalEndpoint;
iPort = endp.Port;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|