⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vc25pro_doc_unasockets.html

📁 Voice Commnucation Components for Delphi
💻 HTML
📖 第 1 页 / 共 4 页
字号:
    This class is used to create server and client sockets and manage the connections.
  <P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">procedure <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.event(event: unaSocketEvent; id, connId: unsigned; data: pointer = nil; size: unsigned = 0); virtual;</SPAN><P />
      This method is called every time new event occur. even parameter specifies the type of event:
      <UL>
	<LI>unaseServerListen - [server] server starts listening</LI>
	<LI>unaseServerConnect - [server] new client has been connected to server</LI>
	<LI>unaseServerData - [server] data is available from one of the clients</LI>
	<LI>unaseServerDisconnect - [server] client has been disconnected from server</LI>
	<LI>unaseServerStop - [server] server stops listening</LI>
	//
	<LI>unaseClientConnect - [client] connection to server has been established</LI>
	<LI>unaseClientData - [client] new data is available from server</LI>
	<LI>unaseClientDisconnect - [client] client has been disconnected from server</LI>
	//
	<LI>unaseThreadStartupError - [thread] some error occurred when starting the server or client connection</LI>
      </UL>
      <BR />id specified the thread id for which the even occur.
      <BR />connId specifies the connection id for this thread for which the even occur.
      <BR />data and size specifies data block available from client or server.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">constructor <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.create();</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">destructor <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.Destroy(); override;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.enter(): [unknown];</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">procedure <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.leave();</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">procedure <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.setParams(timeout: unsigned; threadPoolSize: unsigned);</SPAN><P />
      Sets new parameters for this class.
      <BR />threadPoolSize specifies the number of threads in the pool to be created.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.createConnection(const host, port: string; out connId: unsigned; protocol: int = IPPROTO_TCP; activate: bool = true; const bindToIP: string = '0.0.0.0'; const bindToPort: string = '0'): unsigned;</SPAN><P />
      Creates new client socket. Returns thread id which will handle connections for this socket or 0 if some error occur.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.createServer(const port: string; protocol: int = IPPROTO_TCP; activate: bool = true; backlog: int = SOMAXCONN; udpConnectionTimeout: unsigned = c_defUdpConnTimeout; const bindToIP: string = '0.0.0.0'): unsigned; overload;</SPAN><P />
      Creates new server socket. Returns thread id which will handle connections for this socket or 0 if some error occur.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.createServer(port: word; protocol: int = IPPROTO_TCP; activate: bool = true; backlog: int = SOMAXCONN; udpConnectionTimeout: unsigned = c_defUdpConnTimeout; const bindToIP: string = '0.0.0.0'): unsigned; overload;</SPAN><P />
      Creates new server socket. Returns thread id which will handle connections for this socket or 0 if some error occur.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.activate(id: unsigned): bool;</SPAN><P />
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.isActive(id: unsigned): bool;</SPAN><P />
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.sendData(id: unsigned; data: pointer; size: unsigned; connId: unsigned; noCheck: bool = false; timeout: unsigned = 1000): unsigned;</SPAN><P />
      Sends data to specified connection. Specify the connection id, starting from 1.
      <BR />Returns 0 if data was sent successfully, or specific WSA error otherwise.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.okToWrite(id, connId: unsigned; timeout: unsigned = 100; noCheckState: bool = false): bool;</SPAN><P />
      Returns true if TCP/IP is more or less sure data can be sent now
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.getConnection(id: unsigned; connId: unsigned; timeout: unsigned = 2000; needAcquire: bool = true): <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>;</SPAN><P />
      Returns specified connection. Specify the connection id, starting from 1.
      <BR>WARNING! After returned connection is no longer needed - call its release() method.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.removeConnection(id: unsigned; connId: unsigned): bool;</SPAN><P />
      Closes and removes specified connection. Specify the connection id, starting from 1.
      If thread has no more connections, closes it as well.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.getRemoteHostInfo(socksId, connId: unsigned; out ip, port: string): bool;</SPAN><P />
      Returns IP:Port of remote connection.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.getRemoteHostInfoEx(socksId, connId: unsigned; out ip, port: string; out proto: int): bool;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.closeThread(id: unsigned): bool;</SPAN><P />
      Closes and removes all connection for specified thread. Also stops the thread and makes it available for new connections.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.getThreadByID(id: unsigned; timeout: unsigned = 2000): <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>;</SPAN><P />
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.getSocketError(id: unsigned; needLock: bool = true): int;</SPAN><P />
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">procedure <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.clear(clearServers: bool = false; clearClients: bool = false);</SPAN><P />
      Closes and removes all client or server (or both) connections.
    </TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>.onEvent: unaSocksOnEventEvent;</SPAN><P />
      This event is fired every time new event occur. Refer to event() method for more information.
    </TD></TR></TABLE></DIV>
</DIV>
<DIV><HR /><P />Unit routines<DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_unaSocksOnEventEvent"><SPAN class="source">procedure <SPAN class="class">unaSockets</SPAN>.unaSocksOnEventEvent(sender: tObject; event: unaSocketEvent; id, connId: unsigned; data: pointer; size: unsigned) of object;</SPAN></A><P /></TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_lookupHost"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.lookupHost(const host: string): int; overload;</SPAN></A><P />
  Lookups host name.
  <BR />Host name could be in integer ("194.44.186.254") or alpha ("www.microsoft.com") format or "" for local machine.
  <BR />Returns 0 if successful or specific WSA error otherwise.
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_lookupHost"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.lookupHost(const host: string; out ip: string; list: unaStringList = nil): int; overload;</SPAN></A><P />
  Lookups host name. If the "list" parameter is not nil, it also lists all addresses assigned to a host.
  <BR />Host name could be in integer ("194.44.186.254") or alpha ("www.microsoft.com") format or "" for local machine..
  <BR />Returns 0 if successful or specific WSA error otherwise.
  <BR />Also fills the given ip string with string representation of IP address of the host (if resolved).
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_lookupHost"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.lookupHost(const host: string; defValue: unsigned): unsigned; overload;</SPAN></A><P />
  Lookups host name.
  <BR />Host name could be in integer ("194.44.186.254") or alpha ("www.microsoft.com") format or "" for local machine..
  <BR />If lookup fails, it uses the default parameter value as the IP address of the host.
  <BR />Returns IP address of the host or default parameter value if lookup fails.
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_getHostInfo"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.getHostInfo(ip: uint): string;</SPAN></A><P />
  Lookups host info.
  <BR />Returns the FQDN of the host (if any).
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_listAddresses"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.listAddresses(const host: string; list: unaStringList): int;</SPAN></A><P />
  List all addresses assigned to a host.
  <BR />Host name could be in integer ("194.44.186.254") or alpha ("www.microsoft.com") format or "" for local machine.
  <BR />Returns 0 if successful or specific WSA error otherwise.
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_lookupPort"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.lookupPort(const port: string): int; overload;</SPAN></A><P />
  Lookups port number.
  <BR />Port name could be in integer ("110") or string ("POP3") format.
  <BR />Returns 0 if successful, -1 if port is "" or specific WSA error otherwise.
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_lookupPort"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.lookupPort(const port: string; out port_info: protoent): int; overload;</SPAN></A><P />
  Lookups port number.
  <BR />Port name could be in integer ("110") or string ("POP3") format.
  <BR />Returns 0 if successful, -1 if port is "" or specific WSA error otherwise.
  <BR />Also fills given port_info parameter.
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_startup"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.startup(version: unsigned): int;</SPAN></A><P />
  Startups the Windows sockets by creating unaWsa class instance.
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_shutdown"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.shutdown(): int;</SPAN></A><P />
  Shutdowns the Windows sockets by deleting the unaWsa class instance created in startup() routine.
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_getWSAObject"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.getWSAObject(): <A HREF="#class_unaWSA"><SPAN class="class">unaWSA</SPAN></A>;</SPAN></A><P />
  Returns unaWSA class instance created by a call to startup(), or by unaSocks class.
</TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_ipH2str"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.ipH2str(ip: unsigned): string;</SPAN></A><P /></TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_ipN2str"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.ipN2str(ip: unsigned): string;</SPAN></A><P /></TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_str2ipH"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.str2ipH(const ip: string): unsigned;</SPAN></A><P /></TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_str2ipN"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.str2ipN(const ip: string): unsigned;</SPAN></A><P /></TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_"><SPAN class="source">procedure <SPAN class="class">unaSockets</SPAN>.();</SPAN></A><P /></TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_httpQuery"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.httpQuery(const ip, port, query: string; callback: tIpQueryCallback = nil; timeout: unsigned = 5000): int;</SPAN></A><P /></TD></TR></TABLE></DIV><DIV><P /><TABLE BORDER="1" width="100%"><TR><TD><A NAME="routine_ipQuery"><SPAN class="source">function <SPAN class="class">unaSockets</SPAN>.ipQuery(const ip, port, query: string; proto: int = IPPROTO_TCP; callback: tIpQueryCallback = nil; timeout: unsigned = 5000): int;</SPAN></A><P /></TD></TR></TABLE></DIV></DIV>
</DIV>
<HR><DIV style="text-align: center; font-size: 8pt">&copy; 2000-2007 <A HREF="http://www.lakeofsoft.com/">Lake of Soft, Ltd</A><BR></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -