MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / th_connect

Function th_connect

tests/test_httpd.c:68–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66/* ── Raw-socket test client ───────────────────────────────────── */
67
68static th_sock_t th_connect(int port) {
69#ifdef _WIN32
70 WSADATA wsa;
71 WSAStartup(MAKEWORD(2, 2), &wsa); /* refcounted; cleanup not needed in tests */
72#endif
73 th_sock_t s = socket(AF_INET, SOCK_STREAM, 0);
74 if (s == TH_SOCK_BAD)
75 return TH_SOCK_BAD;
76 struct sockaddr_in addr;
77 memset(&addr, 0, sizeof(addr));
78 addr.sin_family = AF_INET;
79 addr.sin_port = htons((unsigned short)port);
80 addr.sin_addr.s_addr = htonl(0x7F000001); /* 127.0.0.1 */
81 if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
82 th_sock_close(s);
83 return TH_SOCK_BAD;
84 }
85 return s;
86}
87
88static int th_send_all(th_sock_t s, const char *data, size_t len) {
89 size_t off = 0;

Callers 3

th_httpFunction · 0.85
test_httpd.cFile · 0.85
th_http_deadlineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected