网络编程

mac2026-09-24  12

网络编程 数据传输的一种,数据传输三要素:源、目地、长度

怎么写程序: 仿照文件读写: fd=open(“文件名”) read=(fd.buf , len) write=(fd.buf , len)

网络: 服务器:server, TCP重传 fd= socket() bind( 自己的IP,端口)/吧fd和IP端口连接起来/ listen(开始监测数据) accept(接收建立一个连接) send发 recv收

例程: #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> #include <string.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <stdio.h> #include <signal.h>

/* socket

bind listen accept send/recv */

#define SERVER_PORT 8888 #define BACKLOG 10

int main(int argc, char **argv) {

最新回复(0)