Linux下Socket TCP的简单例子(3)

Makefile  :  这个文件值得一提,是一个makefile同时生成两个目标文件

Makefile
#by pafone 2011.02.21
all:server client
    echo "pafone make "
server: socket_server.o
    gcc -o server socket_server.o
client: socket_client.o
    gcc -o client socket_client.o
%.o:%.c
    gcc -c $< -o $@
clean:
    rm -f server client *.o

操作结果:


客户端操作:

[root@localhost socktcp]# ./client 192.168.1.157 1234
#####################################################
socket test      by pafone   19th,April,2009
#####################################################
22 bytes sent
22 bytes sent

服务器端操作:

[root@localhost socktcp]# ./server 1234
#####################################################
socket receive text        by pafone  30th,April,2009
server ip:xxx.xxx.xxx.xxx port:5555
#####################################################
bind seccessful
the server is listenning...
before accept:sockfd_client is 134519408
accept connect.
44bytes receive from connect:-f00k you.
-why?
-how
-**** you.
-why?
-how

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwswgx.html