º¯Êý¹¦ÄÜÊǸ¸×Ó½ø³ÌʹÓÃTCP socket½øÐÐͨÐÅ£¬Ö»ÐèÒª°Ñ×Ö·û´®ÏÔʾ³öÀ´£¬ÔËÐÐÌáʾ´íÎóÊÇ
at line 176 connect ERROR: con_rtn = -1, errno = 22 Invalid argument
²»ÖªºÎ¹Ê£¿
/*
*function : TCP communication with a forked subtask
struct sockaddr_un
{
sa_family_t sun_family; // PF_NUIX or AF_UNIX or AF_LOCAL
char sun_path[UNIX_PATH_MAX]; //name of path;
};
//usr/include/linux/socket.h
typedef unsigned short sa_family_t;
struct sockaddr //this is general structure;
{
unsigned short sa_family; //AF_xxx
char sa_data[14]; // 14 bytes of protocol address
};
//usr/include/netinet/in.h
struct sockaddr_in //internet socket, can convert between above and it;
{
short int sin_family; //address cluster
unsigned short int sin_port; //port number
struct in_addr; //ip address
unsigned char sin_zero[8]; //for the same size as struct sockaddr
};
struct in_addr
{
ÓÉÓÚÎҲŸոսӴ¥socket±à³Ì£¬×Ô¼ºÐ´ÁËÒ»¸ö¼òµ¥³ÌÐò£¬µ«¾ÍÊÇÔÚÔËÐеÄʱºò³öÏֶδíÎó£¬ÎÞ·¨½â¾ö£¬ÏÖÔÚÎÒ°ÑÔ´´úÂëÌù³öÀ´£¬Çë¸÷λ´óϺָÕýһϣ¡Ð»Ð»£¡
#include<stdio.h>
#include<stdlib.h>
#include& ......