tcp.c

来自「飞鸽传书的linux源代码」· C语言 代码 · 共 47 行

C
47
字号
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/socket.h>#include <netinet/in.h>#include <netdb.h>#include <errno.h>#include <glib.h>#include <unistd.h>#include "common.h"static intdestroy_tcp_connection(tcp_con_t *con) {  if (!con)    return -EINVAL;  if (con->self)    freeaddrinfo(con->self);  close(con->soc);  return 0;}static intparse_request(request_msg_t *req,const char *request_string){  size_t len;  long int_val;  char *sp=NULL;  char *ep=NULL;  char *buffer;  ssize_t remains;  int rc=0;  if  ( (!request_string) || (!req) )    return -EINVAL;  buffer=strdup(request_string);  if (!buffer)    return -ENOMEM;  len=strlen(request_string);  _assert(len>0);  remains=len;  /*   * 銉戙偙銉冦儓鐣

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?