当前位置: 技术问答>linux和unix
网络编程问题,高手来看看
来源: 互联网 发布时间:2016-09-28
本文导语: 服务器: #include #include #include #include #include #include #include #include #include #include #include #include int main() { int writen(int fd,const char *vptr,int n); int sock; char ch; int sock_fd; int i=0; int len; FILE *fp1; ch...
服务器:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main()
{
int writen(int fd,const char *vptr,int n);
int sock;
char ch;
int sock_fd;
int i=0;
int len;
FILE *fp1;
char buf[1000];
struct sockaddr_in addr;
if((sock=socket(AF_INET,SOCK_STREAM,0))==-1)
{
printf("socket errorn");
exit(0);
}
memset(&addr,0,sizeof(addr));
addr.sin_family=AF_INET;
addr.sin_port=htons(13000);
if(inet_pton(AF_INET,"192.168.1.102",&addr.sin_addr.s_addr)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main()
{
int writen(int fd,const char *vptr,int n);
int sock;
char ch;
int sock_fd;
int i=0;
int len;
FILE *fp1;
char buf[1000];
struct sockaddr_in addr;
if((sock=socket(AF_INET,SOCK_STREAM,0))==-1)
{
printf("socket errorn");
exit(0);
}
memset(&addr,0,sizeof(addr));
addr.sin_family=AF_INET;
addr.sin_port=htons(13000);
if(inet_pton(AF_INET,"192.168.1.102",&addr.sin_addr.s_addr)