MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / main

Function main

test/clsocket/QueryDayTime.cpp:5–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "ActiveSocket.h" // Include header for active socket object definition
4
5int main(int argc, char **argv)
6{
7 CActiveSocket socket; // Instantiate active socket object (defaults to TCP).
8 char time[50];
9
10 memset(&time, 0, 50);
11
12 //--------------------------------------------------------------------------
13 // Initialize our socket object
14 //--------------------------------------------------------------------------
15 socket.Initialize();
16
17 //--------------------------------------------------------------------------
18 // Create a connection to the time server so that data can be sent
19 // and received.
20 //--------------------------------------------------------------------------
21 // if (socket.Open("time-C.timefreq.bldrdoc.gov", 13))
22 if (socket.Open("192.168.86.196", 6667))
23 {
24 for (int i = 0; i < 100; i++)
25 {
26 //----------------------------------------------------------------------
27 // Send a requtest the server requesting the current time.
28 //----------------------------------------------------------------------
29 char data[1024];
30 sprintf(data, "%s %d", "Hello", i);
31 int len = strlen(data);
32 data[len] = 0;
33 printf("Sending [%s]\n", data);
34 len++;
35 if (socket.Send((const uint8 *)data, len))
36 {
37 //----------------------------------------------------------------------
38 // Receive response from the server.
39 //----------------------------------------------------------------------
40 int rec = socket.Receive(len);
41 if (rec)
42 {
43 uint8 *data = socket.GetData();
44 memcpy(&time, data, len);
45 printf("Received: [%s]\n", time);
46 }
47 }
48 }
49
50 //----------------------------------------------------------------------
51 // Close the connection.
52 //----------------------------------------------------------------------
53 socket.Close();
54 }
55
56 return 1;
57}

Callers

nothing calls this directly

Calls 6

ReceiveMethod · 0.80
GetDataMethod · 0.80
InitializeMethod · 0.45
OpenMethod · 0.45
SendMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected