15 using namespace grafalgo;
21 typedef in_addr_t ipa_t;
22 typedef in_port_t ipp_t;
37 static ipa_t ipAddress(
const char*);
38 static string ip2string(ipa_t);
39 static bool readIpAdr(istream&, ipa_t&);
40 static ipa_t getIpAdr(
const char*);
41 static ipa_t myIpAddress();
44 static void initSockAdr(ipa_t, ipp_t, sockaddr_in*);
45 static void extractSockAdr(sockaddr_in*, ipa_t&, ipp_t&);
46 static ipp_t getSockPort(
int);
47 static ipa_t getSockIp(
int);
48 static ipa_t getPeerIp(
int);
51 static int datagramSocket();
52 static int streamSocket();
53 static bool bind4d(
int, ipa_t, ipp_t);
54 static bool listen4d(
int);
55 static int accept4d(
int);
56 static int accept4d(
int, ipa_t&, ipp_t&);
57 static bool connect4d(
int, ipa_t, ipp_t);
58 static bool nonblock(
int);
61 static int sendto4d(
int,
void*,
int, ipa_t, ipp_t);
62 static int recv4d(
int,
void*,
int);
63 static int recvfrom4d(
int,
void*,
int, ipa_t&, ipp_t&);
66 static bool hasData(
int);
67 static int dataAvail(
int);
68 static int spaceAvail(
int);
69 static bool recvInt(
int, uint32_t&);
70 static bool sendInt(
int, uint32_t);
71 static bool recvIntBlock(
int, uint32_t&);
72 static bool sendIntBlock(
int, uint32_t);
73 static bool recvIntVec(
int, uint32_t*,
int);
74 static bool sendIntVec(
int, uint32_t*,
int);
75 static int recvBuf(
int,
char*,
int);
76 static int sendBuf(
int,
char*,
int);
77 static int recvBufBlock(
int,
char*,
int);
78 static int sendBufBlock(
int,
char*,
int);
79 static int sendString(
int,
const string&);