MCPcopy Create free account
hub / github.com/dermesser/libsocket / connect

Method connect

C++/inetclientstream.cpp:98–119  ·  view source on GitHub ↗

* @brief Set up socket if not already done. * * Creates TCP/IP client socket and connects. Fails if the socket is already set * up. * * @param dsthost Remote host * @param dstport Remote port * @param proto_osi3 `LIBSOCKET_IPv4` or `LIBSOCKET_IPv6` or `LIBSOCKET_BOTH` * @param flags Flags for `socket(2)` */

Source from the content-addressed store, hash-verified

96 * @param flags Flags for `socket(2)`
97 */
98void inet_stream::connect(const char* dsthost, const char* dstport,
99 int proto_osi3, int flags) {
100 if (sfd != -1)
101 throw socket_exception(__FILE__, __LINE__,
102 "inet_stream::connect() - Already connected!",
103 false);
104
105 sfd = create_inet_stream_socket(dsthost, dstport, proto_osi3, flags);
106
107 if (sfd < 0)
108 throw socket_exception(
109 __FILE__, __LINE__,
110 "inet_stream::connect() - Could not create socket");
111
112 host = dsthost;
113 port = dstport;
114 proto = proto_osi3;
115
116 // New file descriptor, therefore reset shutdown flags
117 shut_rd = false;
118 shut_wr = false;
119}
120
121/**
122 * @brief Set up socket if not already done.

Callers

nothing calls this directly

Calls 2

socket_exceptionClass · 0.85

Tested by

no test coverage detected