TCP服務端和客戶端(1)

2021-06-28 02:36:27 字數 622 閱讀 3832

在陳述這個小例項之前,首先將mafile寫出來:

makefile:

all:client server #all規則,他依賴於client和server規則

client:tcp_process.o tcp_client.o #client規則生成客戶端程式

gcc -o client tcp_process.o tcp_client.o

server:tcp_process.o tcp_server.o #server規則生成服務端程式

gcc -o server tcp_process.o tcp_server.o

tcp_process.o: #tcp_process.o規則生成tcp_process.o(這個規則其實也可以不要,但是

#為了看清關係)

gcc -c tcp_process.c -o tcp_process.o

clean: #clean規則,刪除client,server和所有中間檔案

rm -f client server *.o

TCP服務端和客戶端 8

在process.c的基礎上,繼續變換方案,將使用到readv和writev。並且使用到向量方式進行資料的傳送和接收。並在收到相應的訊號後釋放資源。include include include include include static struct iovec vs null,vc null ...

TCP服務端和客戶端 9

繼續對process.c 進行改進,用recvmsg和sendmsg來進行替換。將向量掛載到msghdr的msg iov的成員變數上進行操作。include include include include include include include static struct iovec vs ...

TCP客戶端服務端demo

服務端程式 include include include include include include include int main 列印握手成功的客戶端 struct sockaddr in servaddr socklen t nservlen sizeof servaddr getso...