📄 vc25pro_doc_unasockets.html
字号:
<LI>SOCK_DGRAM - datagram socket
<LI>SOCK_RAW - raw-protocol interface
</UL>
Other values are also defined in WinSock.pas
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.bindToIP: string;</SPAN><P />
Specifies IP address the socket should bind to.
Default value means the socket will bind to any availabe interface.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.bindToPort: string;</SPAN><P />
Specifies Port name or number the socket should bind to.
Default value (0) means the socket will bind to first availabe port number.
Client sockets should always be bind to default port (0), unless you need some special behaviour.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.isActive: bool;</SPAN><P />
Returns True is socket is TCP server socket and is listening,
or if socket is TCP client and is connected, or if socket is bind to UDP port/interface.
Otherwise returns false.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.sndBufSize: unsigned;</SPAN><P />
Size of sending buffer.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.rcvBufSize: unsigned;</SPAN><P />
Size of receiving buffer.
</TD></TR></TABLE></DIV>
<DIV><P /><H4>Class <A NAME="class_unaTcpSocket"><SPAN class="class">unaTcpSocket</SPAN></A>(<A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>)</H4><P />
This class encapsulates TCP socket implementation.
<P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">constructor <A HREF="#class_unaTcpSocket"><SPAN class="class">unaTcpSocket</SPAN></A>.create();</SPAN><P />
Creates TCP socket.
</TD></TR></TABLE></DIV>
<DIV><P /><H4>Class <A NAME="class_unaUdpSocket"><SPAN class="class">unaUdpSocket</SPAN></A>(<A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>)</H4><P />
This class encapsulates UDP socket implementation.
<P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">constructor <A HREF="#class_unaUdpSocket"><SPAN class="class">unaUdpSocket</SPAN></A>.create();</SPAN><P />
Creates UDP socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaUdpSocket"><SPAN class="class">unaUdpSocket</SPAN></A>.recvfrom(var from: sockaddr_in; var data: string; noCheck: bool = true; flags: unsigned = 0; timeout: unsigned = 3000): int; overload;</SPAN><P />
Receives data from remote host. Flags could be 0, MSG_PEEK or MSG_OOB.
<BR />Returns 0 if data was received successfully, in which case from parameter will contain remote address data was sent from.
<BR />Returns specific WSA error otherwise.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaUdpSocket"><SPAN class="class">unaUdpSocket</SPAN></A>.recvfrom(var from: sockaddr_in; data: pointer; noCheck: bool = true; flags: unsigned = 0; timeout: unsigned = 3000): int; overload;</SPAN><P />
Receives data from remote host. Flags could be 0, MSG_PEEK or MSG_OOB.
<BR />NOTE: Memory block pointed by data must be large enough to receive up to MTU bytes.
<BR />Returns size of data if it was received successfully, in which case from parameter will contain remote address data was sent from.
<BR />Returns 0 if the connection has been gracefully closed.
<BR />Returns SOCKET_ERROR if some error ocurred, or -2 if no data can be read at this time.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaUdpSocket"><SPAN class="class">unaUdpSocket</SPAN></A>.sendto(var addr: sockaddr_in; const data: string; flags: unsigned = 0; timeout: unsigned = 3000): unsigned; overload;</SPAN><P />
Sends string of data to remote host. Flags could be 0, MSG_DONTROUTE or MSG_OOB.
<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_unaUdpSocket"><SPAN class="class">unaUdpSocket</SPAN></A>.sendto(var addr: sockaddr_in; const data: string; noCheck: bool = true; flags: unsigned = 0): unsigned; overload;</SPAN><P />
Sends string of data to remote host. Flags could be 0, MSG_DONTROUTE or MSG_OOB.
<BR />If noCheck parameter is true it will not check the socket state before sending the data. This could be used to avoid unnecessary delays.
<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_unaUdpSocket"><SPAN class="class">unaUdpSocket</SPAN></A>.sendto(var addr: sockaddr_in; data: pointer; size: unsigned; flags: unsigned = 0; timeout: unsigned = 3000; noCheck: bool = false): unsigned; overload;</SPAN><P />
Sends block of data to remote host. Flags could be 0, MSG_DONTROUTE or MSG_OOB.
<BR />If noCheck parameter is true it will not check the socket state before sending the data. This could be used to avoid unnecessary delays.
<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_unaUdpSocket"><SPAN class="class">unaUdpSocket</SPAN></A>.sendto(var addr: sockaddr_in; data: pointer; size: unsigned; noCheck: bool = true; flags: unsigned = 0): unsigned; overload;</SPAN><P />
Sends block of data to remote host. Flags could be 0, MSG_DONTROUTE or MSG_OOB.
<BR />If noCheck parameter is true it will not check the socket state before sending the data. This could be used to avoid unnecessary delays.
<BR />Returns 0 if data was sent successfully, or specific WSA error otherwise.
</TD></TR></TABLE></DIV>
<DIV><P /><H4>Class <A NAME="class_unaMulticastSocket"><SPAN class="class">unaMulticastSocket</SPAN></A>(<A HREF="#class_unaUdpSocket"><SPAN class="class">unaUdpSocket</SPAN></A>)</H4><P /><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaMulticastSocket"><SPAN class="class">unaMulticastSocket</SPAN></A>.closeSocket(): int; override;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaMulticastSocket"><SPAN class="class">unaMulticastSocket</SPAN></A>.senderCreate(ttl: DWORD = IP_DEFAULT_MULTICAST_TTL; enableLoop: DWORD = 0; noBind: bool = true): int;</SPAN><P />
Creates a mulicast sender with specified parameters.
If noBind is false (default) it also binds a socket to interface specified
in bindToIP property (or to default interface if bindToIP is '0.0.0.0').
Returns 0 for success, or socket-specific error code otherwise.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaMulticastSocket"><SPAN class="class">unaMulticastSocket</SPAN></A>.senderSend(data: pointer; len: int; noCheck: bool = false): int; overload;</SPAN><P />
Sends a multicast packet to a grop specified by host and port properties.
Returns 0 for success, or socket-specific error code otherwise.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaMulticastSocket"><SPAN class="class">unaMulticastSocket</SPAN></A>.senderSend(const data: string; noCheck: bool = false): int; overload;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaMulticastSocket"><SPAN class="class">unaMulticastSocket</SPAN></A>.recGroupJoin(const groupAddr: string): int;</SPAN><P />
Joins the specified group.
Also binds a socket to port and interface specified by port and bindToIP property
(or default interface is bindToIp = '0.0.0.0').
Use recvfrom() to receive multicast packets from a group(s).
Returns 0 for success, or socket-specific error code otherwise.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaMulticastSocket"><SPAN class="class">unaMulticastSocket</SPAN></A>.recGroupDrop(const groupAddr: string = ''): int;</SPAN><P />
Leaves the specified group (or a group it joined in a previous successfull call to recGroupJoin() if groupAddr = '').
Returns 0 for success, or socket-specific error code otherwise.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaMulticastSocket"><SPAN class="class">unaMulticastSocket</SPAN></A>.isReady(sender: bool = true): bool;</SPAN><P /></TD></TR></TABLE></DIV>
<DIV><P /><H4>Class <A NAME="class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>(<SPAN class="class">unaObject</SPAN>)</H4><P />
This is base class for connection between two sockets.
<P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.acquire(timeout: unsigned): bool;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">constructor <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.create(thread: <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>; connId: unsigned; socket: <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>; addr: pSockAddrIn = nil);</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">procedure <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.BeforeDestruction(); override;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.send(data: pointer; size: unsigned; noCheck: bool = false): unsigned;</SPAN><P />
Sends data to remote socket.
<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_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.okToWrite(timeout: unsigned = 100; noCheckState: bool = false): bool;</SPAN><P />
Returns true if there are some chances data could be sent right now..
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.compareAddr(const addr: sockaddr_in): bool;</SPAN><P />
Compares given address with address of local socket.
<BR />Returns true if given address belongs to local socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">procedure <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.release();</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.socket: <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>;</SPAN><P />
Returns local socket class instance.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.paddr: PSockAddrIn;</SPAN><P />
Returns pointer to sockaddr_in structure filled by local socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>.connId: unsigned;</SPAN><P />
id of this connection.
</TD></TR></TABLE></DIV>
<DIV><P /><H4>Class <A NAME="class_unaSocketsConnections"><SPAN class="class">unaSocketsConnections</SPAN></A>(<SPAN class="class">unaIdList</SPAN>)</H4><P /><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocketsConnections"><SPAN class="class">unaSocketsConnections</SPAN></A>.getId(item: pointer): int64; override;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocketsConnections"><SPAN class="class">unaSocketsConnections</SPAN></A>.get_connection(connId: unsigned; timeout: unsigned = 2000): <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>;</SPAN><P /></TD></TR></TABLE></DIV>
<DIV><P /><H4>Class <A NAME="class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>(<SPAN class="class">unaThread</SPAN>)</H4><P />
This thread is used to handle server or client connections.
<P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>.execute(globalIndex: unsigned): int; override;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">constructor <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>.create(socks: <A HREF="#class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>; socket: <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>; isServer: bool; id: unsigned);</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">procedure <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>.BeforeDestruction(); override;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">destructor <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>.Destroy(); override;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>.getConnection(connId: unsigned; timeout: unsigned = 2000): <A HREF="#class_unaSocksConnection"><SPAN class="class">unaSocksConnection</SPAN></A>;</SPAN><P />
Returns sockets connection for specified connection id.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>.socket: <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>.socketError: integer;</SPAN><P /></TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">property <A HREF="#class_unaSocksThread"><SPAN class="class">unaSocksThread</SPAN></A>.isServer: bool;</SPAN><P /></TD></TR></TABLE></DIV>
<DIV><P /><H4>Class <A NAME="class_unaSocksThreads"><SPAN class="class">unaSocksThreads</SPAN></A>(<SPAN class="class">unaIdList</SPAN>)</H4><P /><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocksThreads"><SPAN class="class">unaSocksThreads</SPAN></A>.getId(item: pointer): int64; override;</SPAN><P /></TD></TR></TABLE></DIV>
<DIV><P /><H4>Class <A NAME="class_unaSocks"><SPAN class="class">unaSocks</SPAN></A>(<SPAN class="class">unaObject</SPAN>)</H4><P />
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -