CSocket.getsockname Method | |
Get the local name for a socket.
Namespace:
VO
Assembly:
VOInternetClasses (in VOInternetClasses.dll) Version: 2.19
Syntax VIRTUAL METHOD getsockname(
cName REF STRING,
nPort REF LONG
) AS LOGIC
public virtual bool getsockname(
ref string cName,
ref int nPort
)
Request Example
View SourceParameters
- cName
- Type: String
Reference to a string which is to receive the peer's IP address. - nPort
- Type: Long
Reference to a DWORD value to receive the peer's port number
Return Value
Type:
Logic
TRUE if successful; otherwise, FALSE.
Remarks
This method gets the local address and port number of the socket.
Examples
The following example demonstrates the use of this method:
1FUNCTION SimpleTest() AS VOID PASCAL
2LOCAL oSocket AS CSocket
3LOCAL cIP AS STRING
4LOCAL nPort AS INT
5oSocket := CSocket{SOCK_STREAM}
6IF oSocket:bind(7, NULL_STRING, AF_INET)
7oSocket:GetSockName(@cIP, @nPort)
8? "Local IP ", cIP, ", port: ", NTrim(nPort)
9ENDIF
10oSocket:Close()
11RETURN
See Also