当前位置: 技术问答>linux和unix
请大家帮我看一下我这个回射服务器程序哪里出错了???
来源: 互联网 发布时间:2016-08-10
本文导语: #include"unp.h" int main(int argc,char **argv) { int listenfd,confd; struct sockaddr_in server,client,peer; char receive[MAXSIZE],send[MAXSIZE]; int client_len,peer_len; char p[16]; client_len = sizeof(client); peer_len = sizeof(peer); listenfd = Socket(AF_...
#include"unp.h"
int main(int argc,char **argv)
{
int listenfd,confd;
struct sockaddr_in server,client,peer;
char receive[MAXSIZE],send[MAXSIZE]; int client_len,peer_len;
char p[16];
client_len = sizeof(client);
peer_len = sizeof(peer);
listenfd = Socket(AF_INET,SOCK_STREAM,0);
bzero(&server,sizeof(server));
server.sin_port = htons(SERV_PORT);
server.sin_family = AF_INET;
server.sin_addr.s_addr = htonl(INADDR_ANY);
Bind(listenfd,(struct sockaddr *)&server,sizeof(server));
Listen(listenfd,10);
while(1)
{
if((confd = accept(listenfd,(struct sockaddr *)&client,&client_len))
int main(int argc,char **argv)
{
int listenfd,confd;
struct sockaddr_in server,client,peer;
char receive[MAXSIZE],send[MAXSIZE]; int client_len,peer_len;
char p[16];
client_len = sizeof(client);
peer_len = sizeof(peer);
listenfd = Socket(AF_INET,SOCK_STREAM,0);
bzero(&server,sizeof(server));
server.sin_port = htons(SERV_PORT);
server.sin_family = AF_INET;
server.sin_addr.s_addr = htonl(INADDR_ANY);
Bind(listenfd,(struct sockaddr *)&server,sizeof(server));
Listen(listenfd,10);
while(1)
{
if((confd = accept(listenfd,(struct sockaddr *)&client,&client_len))