当前位置: 技术问答>linux和unix
请教客户端在solaris上,服务器端在windows上的socket问题
来源: 互联网 发布时间:2016-01-21
本文导语: 在solaris上的客户端大体代码: #define SERVER_PORT 8888 #define CLIENT_PORT 8888 #define BUFFER_SIZE 10000 unsigned char * content = new unsigned char[5]; content[0] = 0x02; content[1] = 0; content[2] = 0; len = 10; content[3] = len/256; content[4] ...
在solaris上的客户端大体代码:
#define SERVER_PORT 8888
#define CLIENT_PORT 8888
#define BUFFER_SIZE 10000
unsigned char * content = new unsigned char[5];
content[0] = 0x02;
content[1] = 0;
content[2] = 0;
len = 10;
content[3] = len/256;
content[4] = len%256;
char buf[BUFFER_SIZE];
int servfd,clifd,length = 0;
struct sockaddr_in servaddr,cliaddr;
socklen_t socklen = sizeof(servaddr);
struct hostent *host;
if ((clifd = socket(AF_INET,SOCK_STREAM,0)) h_addr);
if (connect(clifd,(struct sockaddr*)&servaddr, socklen)
#define SERVER_PORT 8888
#define CLIENT_PORT 8888
#define BUFFER_SIZE 10000
unsigned char * content = new unsigned char[5];
content[0] = 0x02;
content[1] = 0;
content[2] = 0;
len = 10;
content[3] = len/256;
content[4] = len%256;
char buf[BUFFER_SIZE];
int servfd,clifd,length = 0;
struct sockaddr_in servaddr,cliaddr;
socklen_t socklen = sizeof(servaddr);
struct hostent *host;
if ((clifd = socket(AF_INET,SOCK_STREAM,0)) h_addr);
if (connect(clifd,(struct sockaddr*)&servaddr, socklen)