Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
LInet::ServerInit
#include "ltwrappr.h"
virtual L_INT LInet::ServerInit(nPort)
L_INT nPort; |
/* port on which to listen */ |
Sets up a port to act as a server to which other computers can connect.
Parameter |
Description |
|
nPort |
Port number on which to listen for incoming connections. Some commonly used values include: |
|
|
Value |
Meaning |
|
0x015 |
FTP |
|
0x050 |
Web server |
|
0x077 |
News |
|
0x019 |
|
|
0x017 |
Telnet |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
You must initialize the LEADTOOLS Peer-to-Peer DLL using LInet::StartUp before calling this function.
Required DLLs and Libraries
LTNET For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
LInet::Connect, LInet::Close, LInet::AcceptConnect, LInet::ServerShutdown, LInet::StartUp, LInet::ShutDown, Class Members |
Example
// The user should derive a class from LInet to support the OnConnectRequest callback function // suppose it was named as LUserInet class LUserInetSI : public LInet { protected: virtual L_INT OnConnectRequest(LInet *plConnection, L_INT nError); }; L_INT LInet__ServerInitExample() { L_INT nRet; LUserInetSI UserInet; nRet = UserInet.StartUp(); if(nRet != SUCCESS) return nRet; nRet = UserInet.ServerInit(1000); if(nRet != SUCCESS) return nRet; // other operations nRet = UserInet.ServerShutdown(); if(nRet != SUCCESS) return nRet; nRet = UserInet.ShutDown(); if(nRet != SUCCESS) return nRet; return SUCCESS; } L_INT LUserInetSI::OnConnectRequest(LInet *plConnection, L_INT nError) { L_CHAR *pName; L_TCHAR szString[150] = TEXT("\0"); L_INT nRet = SUCCESS; if (nError != SUCCESS) return nError; // retrieve the remote computer name if ((pName = plConnection->GetHostName(HOST_NAME_IP)) == NULL) return FAILURE; wsprintf(szString, TEXT("Some one requires connecting to you, his TCP/IP: %s, accept him ?"), pName); if (IDYES == MessageBox(NULL, szString, TEXT(""), MB_YESNO)) { if ((nRet = AcceptConnect(plConnection)) != SUCCESS) return nRet; MessageBox(NULL, TEXT("Remote computer accepted."), TEXT(""), MB_OK); } // other operations // close the connection Close(plConnection); return nRet; }