- 论坛徽章:
- 0
|
#include
#include
#include
#include
#include
#include
#include
#include
#include
void main(){
int sock;
struct sockaddr_in server,client;
int recvd,snd;
int structlength;
char * server_ip = "128.168.10.1";/*server ip address*/
int port = 8888;
char recvbuf[2000],sendbuf[2000];
char str1[]="I have received:\n";
memset((char *)&server,0,sizeof(server));
server.sin_family = AF_INET;
server.sin_addr.s_addr = inet_addr(server_ip);
server.sin_port = htons(port);
memset((char *)&client,0,sizeof(client));
client.sin_family = AF_INET;
client.sin_addr.s_addr = htonl(INADDR_ANY);
client.sin_port = htons(port);
if((sock = socket (AF_INET,SOCK_DGRAM,0))
structlength = sizeof(server);
if( bind(sock,(struct sockaddr *) &server,structlength)
}
close(sock);
}
/*
gcc -o server server.c
./server
*/
/*client.php*/
Refer from www.zaoxue.com
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/29515/showart_407642.html |
|