Y
yjlucky
Unregistered / Unconfirmed
GUEST, unregistred user!
有段c语言写的客户端:
static int tcp_open(void)
{
int sock;
int ret;
struct sockaddr_in servaddr;
sock = socket (AF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
return -11;
}
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr( ServerAddr );
servaddr.sin_port = htons ( Portno );
ret = connect ( sock, (void *)&servaddr, sizeof(servaddr) );
if (ret < 0)
{
close (sock);
return -1;
}
return (sock);
}
我要用delphi的TclientSocket改写,但是我把TclientSocket的address和port设置成相应的,然后运行ClientSocket.active:=true的时候会报错,为什么?
static int tcp_open(void)
{
int sock;
int ret;
struct sockaddr_in servaddr;
sock = socket (AF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
return -11;
}
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr( ServerAddr );
servaddr.sin_port = htons ( Portno );
ret = connect ( sock, (void *)&servaddr, sizeof(servaddr) );
if (ret < 0)
{
close (sock);
return -1;
}
return (sock);
}
我要用delphi的TclientSocket改写,但是我把TclientSocket的address和port设置成相应的,然后运行ClientSocket.active:=true的时候会报错,为什么?