张
张无忌
Unregistered / Unconfirmed
GUEST, unregistred user!
我刚才找到安全设置TClientSocket本机端口的办法了,代码如下:应该说这个是
最安全的办法。
procedure TForm1.ClientSocket1Lookup(Sender: TObject;
Socket: TCustomWinSocket);
var
SockAddrIn: TSockAddrIn;
iRc:Integer;
begin
SockAddrIn.sin_family := AF_INET;
SockAddrIn.sin_addr.S_addr := 0;
SockAddrIn.sin_port := htons(1979);
iRc:=bind(ClientSocket1.Socket.SocketHandle, SockAddrIn, sizeof(TSockAddrIn));
if iRc= 0 then
ShowMessage('绑定成功!')
else
ShowMessage(Format('%d',[WSAGetLastError()]));
最安全的办法。
procedure TForm1.ClientSocket1Lookup(Sender: TObject;
Socket: TCustomWinSocket);
var
SockAddrIn: TSockAddrIn;
iRc:Integer;
begin
SockAddrIn.sin_family := AF_INET;
SockAddrIn.sin_addr.S_addr := 0;
SockAddrIn.sin_port := htons(1979);
iRc:=bind(ClientSocket1.Socket.SocketHandle, SockAddrIn, sizeof(TSockAddrIn));
if iRc= 0 then
ShowMessage('绑定成功!')
else
ShowMessage(Format('%d',[WSAGetLastError()]));