Skip to content

Commit

Permalink
Add tpc/bin/sendoob.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuo committed Aug 22, 2017
1 parent b181e94 commit 475e9be
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tpc/bin/sendoob.cc
@@ -0,0 +1,31 @@
#include "InetAddress.h"
#include "Socket.h"
#include <string.h>

int main(int argc, char* argv[])
{
if (argc < 3)
{
printf("Usage:\n %s hostname port\n", argv[0]);
return 0;
}

int port = atoi(argv[2]);
InetAddress addr(port);
const char* hostname = argv[1];
if (InetAddress::resolve(hostname, &addr))
{
Socket sock(Socket::createTCP());
if (sock.connect(addr) == 0)
{
const char* buf = "hello";
ssize_t nw = ::send(sock.fd(), buf, strlen(buf), MSG_OOB);
printf("sent %zd bytes\n", nw);
getchar();
}
else
{
perror("connect");
}
}
}

0 comments on commit 475e9be

Please sign in to comment.