I
iknowabc
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟编写一个socket封装程序,下面tcp_socket是在create创建的。
function TMyUDPSocket.bind(ip:string;port:integer):boolean;
var
addr_server:TSOCKADDR;
err:integer;
begin
result:=false;
//Assert(TCP_Socket<>nil);
UDPPort:=Port;
ZeroMemory(@addr_server,sizeof(addr_server));
with addr_server do
begin
sin_family :=AF_INET;
sin_port :=htons(UDPPort);
sin_addr.S_addr :=inet_addr(pchar(ip));
end;
err:=bind(UDP_Socket,addr_server,sizeof(addr_server));
if err<>0 then exit;
result:=true;
end;
编译时老是说'bind'那一行有以下错误:
Incompatible types: 'string' and 'integer'
Incompatible types: 'integer' and 'sockaddr_in'
Incompatible types: 'integer' and 'boolean'
不知哪里错了,我查了bind的原型,是这样的参数顺序呀?
function TMyUDPSocket.bind(ip:string;port:integer):boolean;
var
addr_server:TSOCKADDR;
err:integer;
begin
result:=false;
//Assert(TCP_Socket<>nil);
UDPPort:=Port;
ZeroMemory(@addr_server,sizeof(addr_server));
with addr_server do
begin
sin_family :=AF_INET;
sin_port :=htons(UDPPort);
sin_addr.S_addr :=inet_addr(pchar(ip));
end;
err:=bind(UDP_Socket,addr_server,sizeof(addr_server));
if err<>0 then exit;
result:=true;
end;
编译时老是说'bind'那一行有以下错误:
Incompatible types: 'string' and 'integer'
Incompatible types: 'integer' and 'sockaddr_in'
Incompatible types: 'integer' and 'boolean'
不知哪里错了,我查了bind的原型,是这样的参数顺序呀?