File: connect.cpp

package info (click to toggle)
yrmcds 1.0.4-6
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 924 kB
  • ctags: 1,346
  • sloc: cpp: 9,634; sh: 133; makefile: 97
file content (22 lines) | stat: -rw-r--r-- 517 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cybozu/tcp.hpp>

#include <iostream>

int main(int argc, char** argv) {
    if( argc != 3 ) {
        std::cout << "Usage: connect.exe HOST PORT" << std::endl;
        return 0;
    }

    const char* node = argv[1];
    std::uint16_t port = static_cast<std::uint16_t>( std::stoi(argv[2]) );

    int s = cybozu::tcp_connect(node, port, 5);
    if( s == -1 ) {
        std::cout << "failed." << std::endl;
    } else {
        std::cout << "connected." << std::endl;
        close(s);
    }
    return 0;
}