#include <iostream>
#include <cstdlib>
#ifdef CCXX_NAMESPACES
using namespace std;
#endif
{
protected:
public:
};
{
cout << "binding segsize: " << getSegmentSize() << endl;
}
{
cout << "accepting from: " << ia << ":" << port << endl;;
return true;
}
int main(int argc, char *argv[])
{
int i;
addr = "255.255.255.255";
cout << "testing addr: " << addr << ":" << 4096 << endl;
addr = "127.0.0.1";
cout << "binding for: " << addr << ":" << 4096 << endl;
Thread::setException(Thread::throwException);
try {
myTCPSocket server(addr);
while(server.isPendingConnection(30000)) {
tcp <<
"welcome to " << addr <<
"; segment size=" << tcp.
getSegmentSize() << endl;
tcp <<
"connected from " << tcp.
getPeer(&port) << endl;
if(tcp.
isPending(Socket::pendingInput, 2000)) {
tcp >> i;
tcp << "user entered " << i << endl;
}
tcp << "exiting now" << endl;
}
}
catch(SockException& e) {
cout << e.getString() << ": " << e.getSystemErrorString() << endl;
exit(-1);
}
cout << "timeout after 30 seconds inactivity, exiting" << endl;
return 0;
}
#define InetAddress
Definition address.h:75
#define InetHostAddress
Definition address.h:76
IPV4Host getPeer(tpport_t *port=NULL) const
Definition socket.h:523
TCP sockets are used for stream based connected sessions between two sockets.
Definition socket.h:1396
TCP streams are used to represent TCP client connections to a server by TCP protocol servers for acce...
Definition socket.h:1632
void connect(const IPV4Host &host, tpport_t port, unsigned mss=536)
Create a TCP stream by connecting to a TCP socket (on a remote machine).
void disconnect(void)
Disconnect the current session and prepare for a new one.
int getSegmentSize(void)
Get protocol segment size.
bool isPending(Pending pend, timeout_t timeout=TIMEOUT_INF)
Get the status of pending stream data.
unsigned short tpport_t
Transport Protocol Ports.
Definition address.h:86
Network addresses and sockets related classes.