1475e9be4SShuo Chen#include "InetAddress.h" 2475e9be4SShuo Chen#include "Socket.h" 3475e9be4SShuo Chen#include <string.h> 4475e9be4SShuo Chen 524ca08a8SShuo Chen// RFC6093: On the Implementation of the TCP Urgent Mechanism, 2011/01. 624ca08a8SShuo Chen// Which recommends against the use of urgent mechanism. 724ca08a8SShuo Chen 8475e9be4SShuo Chenint main(int argc, char* argv[]) 9475e9be4SShuo Chen{ 10475e9be4SShuo Chen if (argc < 3) 11475e9be4SShuo Chen { 12475e9be4SShuo Chen printf("Usage:\n %s hostname port\n", argv[0]); 13475e9be4SShuo Chen return 0; 14475e9be4SShuo Chen } 15475e9be4SShuo Chen 16475e9be4SShuo Chen int port = atoi(argv[2]); 1724ca08a8SShuo Chen InetAddress addr; 18475e9be4SShuo Chen const char* hostname = argv[1]; 1924ca08a8SShuo Chen if (InetAddress::resolve(hostname, port, &addr)) 20475e9be4SShuo Chen { 2124ca08a8SShuo Chen Socket sock(Socket::createTCP(addr.family())); 22475e9be4SShuo Chen if (sock.connect(addr) == 0) 23475e9be4SShuo Chen { 24475e9be4SShuo Chen const char* buf = "hello"; 25475e9be4SShuo Chen ssize_t nw = ::send(sock.fd(), buf, strlen(buf), MSG_OOB); 26475e9be4SShuo Chen printf("sent %zd bytes\n", nw); 27475e9be4SShuo Chen getchar(); 28475e9be4SShuo Chen } 29475e9be4SShuo Chen else 30475e9be4SShuo Chen { 31475e9be4SShuo Chen perror("connect"); 32475e9be4SShuo Chen } 33475e9be4SShuo Chen } 34475e9be4SShuo Chen} 35