• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 25456501308

06 May 2026 07:29PM UTC coverage: 55.935% (-0.8%) from 56.7%
25456501308

Pull #2011

github

web-flow
Merge 7ad262960 into 7054e405e
Pull Request #2011: Single-file CI and code style adoption

14612 of 26123 relevant lines covered (55.94%)

462107.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/trick_source/sim_services/VariableServer/VariableServer_open_additional_servers.cpp
1

2
#include <stdio.h>
3
#include "trick/VariableServer.hh"
4
#include "trick/message_proto.h"
5
#include "trick/message_type.h"
6

7
#include "trick/TCPConnection.hh"
8
#include "trick/UDPConnection.hh"
9
#include "trick/TCPClientListener.hh"
10

11
int Trick::VariableServer::create_tcp_socket(const char * address, unsigned short in_port ) {
×
12
    // Open a VariableServerListenThread to manage this server
13

14
    TCPClientListener * listener = new TCPClientListener();
×
15
    int status = listener->initialize(address, in_port);
×
16

17
    if (status != 0) {
×
18
        message_publish(MSG_ERROR, "ERROR: Could not establish additional listen port at address %s and port %d for Variable Server.\n", address, in_port);
×
19
        delete listener;
×
20
        return 0;
×
21
    }
22

23
    std::string set_address = listener->getHostname();
×
24
    int set_port = listener->getPort();
×
25

26
    Trick::VariableServerListenThread * new_listen_thread = new Trick::VariableServerListenThread(listener) ;
×
27

28
    new_listen_thread->copy_cpus(listen_thread.get_cpus()) ;
×
29
    new_listen_thread->create_thread() ;
×
30
    additional_listen_threads[new_listen_thread->get_pthread_id()] = new_listen_thread ;
×
31

32
    message_publish(MSG_INFO, "Created TCP variable server %s: %d\n", set_address.c_str(), set_port);
×
33

34
    return 0 ;
×
35
}
×
36

37
int Trick::VariableServer::create_udp_socket(const char * address, unsigned short in_port ) {
×
38
    // UDP sockets are created without a listen thread, and represent only 1 session
39
    // Create a VariableServerSessionThread to manage this session
40

41
    UDPConnection * udp_conn = new UDPConnection();
×
42
    int status = udp_conn->initialize(address, in_port);
×
43
    if ( status != 0 ) {
×
44
        message_publish(MSG_ERROR, "ERROR: Could not establish UDP port at address %s and port %d for Variable Server.\n", address, in_port);
×
45
        delete udp_conn;
×
46
        return 0;
×
47
    }
48

49
    std::string set_address = udp_conn->getHostname();
×
50
    int set_port = udp_conn->getPort();
×
51

52
    Trick::VariableServerSessionThread * vst = new Trick::VariableServerSessionThread() ;
×
53

54
    vst->set_connection(udp_conn);
×
55
    vst->copy_cpus(listen_thread.get_cpus()) ;
×
56
    vst->create_thread() ;
×
57

58
    message_publish(MSG_INFO, "Created UDP variable server %s: %d\n", set_address.c_str(), set_port);
×
59

60
    return 0 ;
×
61
}
×
62

63
int Trick::VariableServer::create_multicast_socket(const char * mcast_address, const char * address, unsigned short in_port ) {
×
64

65
    // Multicast sockets are created without a listen thread, and represent only 1 session
66
    // Create a VariableServerSessionThread to manage this session
67

68
    if (mcast_address == NULL || mcast_address[0] == '\0') {
×
69
        message_publish(MSG_ERROR, "Multicast address must be defined.\n");
×
70
        return -1;
×
71
    }
72

73
    MulticastGroup * multicast = new MulticastGroup();
×
74
    message_publish(MSG_INFO, "Created UDP variable server %s: %d\n", address, in_port);
×
75

76
    int status = multicast->initialize_with_receiving(address, mcast_address, in_port);
×
77
    if ( status != 0 ) {
×
78
        message_publish(MSG_ERROR, "ERROR: Could not establish Multicast port at address %s and port %d for Variable Server.\n", address, in_port);
×
79
        delete multicast;
×
80
        return 0;
×
81
    }
82

83
    std::string set_address = multicast->getHostname();
×
84
    int set_port = multicast->getPort();
×
85

86
    Trick::VariableServerSessionThread * vst = new Trick::VariableServerSessionThread() ;
×
87

88
    vst->set_connection(multicast);
×
89
    vst->copy_cpus(listen_thread.get_cpus()) ;
×
90
    vst->create_thread() ;
×
91

92
    message_publish(MSG_INFO, "Multicast variable server output %s:%d\n", mcast_address, set_port) ;
×
93

94
    return 0 ;
×
95
}
×
96

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc