1#include "InetAddress.h"
2#include "Socket.h"
3#include <string.h>
4
5// RFC6093: On the Implementation of the TCP Urgent Mechanism, 2011/01.
6// Which recommends against the use of urgent mechanism.
7
8int main(int argc, char* argv[])
9{
10  if (argc < 3)
11  {
12    printf("Usage:\n  %s hostname port\n", argv[0]);
13    return 0;
14  }
15
16  int port = atoi(argv[2]);
17  InetAddress addr;
18  const char* hostname = argv[1];
19  if (InetAddress::resolve(hostname, port, &addr))
20  {
21    Socket sock(Socket::createTCP(addr.family()));
22    if (sock.connect(addr) == 0)
23    {
24      const char* buf = "hello";
25      ssize_t nw = ::send(sock.fd(), buf, strlen(buf), MSG_OOB);
26      printf("sent %zd bytes\n", nw);
27      getchar();
28    }
29    else
30    {
31      perror("connect");
32    }
33  }
34}
35