vc25pro_doc_unasockets.html
来自「Voice Commnucation Components for Delphi」· HTML 代码 · 共 391 行 · 第 1/4 页
HTML
391 行
Closes and destroys the socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.getSocket(forceCreate: bool = false): tSocket;</SPAN><P />
Returns socket handle.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.getSockAddr(var addr: sockaddr_in): int;</SPAN><P />
Returns sockaddr_in structure filled with address:port values which corresponds to the socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.listen(backlog: int = SOMAXCONN): int;</SPAN><P />
Binds the socket to specified (or auto-assigned port) number and starts listening for incoming connections.
<BR />Returns true if socket is already in listening mode.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.connect(addr: pSockAddrIn = nil): int;</SPAN><P />
Connects the socket to remote host.
<BR>Returns:
<UL>
<LI>0 - socket has been connected successfully</LI>
<LI>or specific WSA error (which is not zero)</LI>
</UL>
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.close(graceful: bool = true): int;</SPAN><P />
Closes the socket. If graceful = true, socket will gracefully close all operations, and then disconnect.
<BR />Returns 0 if no error occurred (or socket was not connected/listening), or specific WSA error (which is not zero).
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.accept(out socket: tSocket): [unknown];</SPAN><P />
Blocks until new connection will be established with socket, or timeout value expires.
<BR />Returns new connected client socket, or nil if timeout or error occur.
<BR /><STRONG>NOTE</STRONG>: this method should be used with TCP sockets only.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.shutdown(how: int): int;</SPAN><P />
Closes the open socket. how can have the following values:
<UL>
<LI>SD_RECEIVE - complete and disable receiving operations</LI>
<LI>SD_SEND - complete and disable sending operations</LI>
<LI>SD_BOTH - complete and disable both operations</LI>
</UL>
<BR />Returns 0 if no error occurred, or specific WSA error.
<BR /><STRONG>NOTE</STRONG>: do not try to reuse the socket after it has been successfully shut down.
Call close() to clean up the socket before reusing it again.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.isConnected(timeout: unsigned = 0): bool;</SPAN><P />
Returns true, if socket is connected to remote host, and there was no error.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.isListening(): bool;</SPAN><P />
Returns true, if socket is listening, and there was no error
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.okToRead(timeout: unsigned = 0; noCheckState: bool = false): bool;</SPAN><P />
Returns True if there are some chances data could be sent now.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.okToWrite(timeout: unsigned = 0; noCheckState: bool = false): bool;</SPAN><P />
Returns True if there are some chances data could be sent now.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.read(const buf: pointer; var size: unsigned): [unknown];</SPAN><P />
Returns -1, if socket is not connected or no data were available within timeout period.
<BR />Returns 0, if data was read, and size specifies actual amount of data read.
<BR />Otherwise returns specific WSA error.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.readString(noCheck: bool = false): string;</SPAN><P />
Reads a string from socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.waitForData(): [unknown];</SPAN><P />
Waits until data will be available to read from socket or timeout expire.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.getPendingDataSize(noCheckState: bool = false): unsigned;</SPAN><P />
Returns number of bytes available to read from socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.send(buf: pointer; size: unsigned; noCheck: bool = false): int; overload;</SPAN><P />
Sends data into socket.
<BR />Returns 0 or specific WSA error.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.send(const value: string; noCheck: bool = false): int; overload;</SPAN><P />
Sends a string into socket.
<BR />Returns 0 or specific WSA error.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.getOptBool(opt: int): bool;</SPAN><P />
Returns boolean option of the socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.getOptInt(opt: int): int;</SPAN><P />
Returns integer option of the socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.setOptBool(opt: int; value: bool): int;</SPAN><P />
Sets boolean option of the socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.setOptInt(opt: int; value: int): int;</SPAN><P />
Sets integer option of the socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.setPort(const port: string): bool; overload;</SPAN><P />
Sets remote port number for the socket. This value will be used to connect socket to.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.setPort(port: word): bool; overload;</SPAN><P />
Sets remote port number for the socket. This value will be used to connect socket to.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.getPort(): string;</SPAN><P />
Returns remote port value as string.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.getPortInt(): word;</SPAN><P />
Returns remote port value as word.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.getGeneralMTU(): unsigned;</SPAN><P />
Returns maximum transmission unit (MTU) size.
<BR /><STRONG>NOTE</STRONG>: this value should not be used as real MTU size, but only as an estimation for most cases.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.getMTU(): uint;</SPAN><P />
Returns maximum transmission unit (MTU) size for connected socket.
</TD></TR></TABLE><P /><TABLE BORDER="1" width="100%"><TR><TD><SPAN class="source">function <A HREF="#class_unaSocket"><SPAN class="class">unaSocket</SPAN></A>.bindSocketToPort(port: int): int;</SPAN><P />
Binds the socket to specified port.
If port value is -1 (default), this function uses the bindToPort property as a port number to bind to.
If port value is 0, this function auto-assigns first available port number for socket.
</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>.host: string;</SPAN><P />
Specifies remote host value for the socket. This value will be used to connect socket to.
</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>.socketAddressFamily: int;</SPAN><P />
Specifies socket address family. For most applications you should use the AF_INET value.
</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>.socketProtocol: int;</SPAN><P />
Specifies protocol number to be used with socket. Following values are defined:
<UL>
<LI>IPPROTO_ICMP - control message protocol</LI>
<LI>IPPROTO_IGMP - group management protocol</LI>
<LI>IPPROTO_TCP - tcp</LI>
<LI>IPPROTO_UDP - user datagram protocol</LI>
</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>.socketType: int;</SPAN><P />
Specifies socket type to be used with socket. Following values are defined:
<UL>
<LI>SOCK_STREAM - stream socket
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?