MCPcopy Create free account
hub / github.com/acl-dev/acl / service_create

Function service_create

lib_acl/samples/dgate/service_main.cpp:70–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70SERVICE *service_create(const char *local_ip, short local_port,
71 const char *dns_ip, short dns_port)
72{
73 const char *myname = "service_create";
74 SERVICE *service;
75 ACL_VSTREAM *sstream;
76 char addr[64];
77
78 // �����ṩ TCP ��ʽ��ѯʱ�ļ�����
79 snprintf(addr, sizeof(addr), "%s:%d", local_ip, local_port);
80 sstream = acl_vstream_listen_ex(addr, 128, ACL_NON_BLOCKING, 1024, 10);
81 if (sstream == NULL) {
82 acl_msg_error("%s(%d): can't listen on addr(%s)",
83 myname, __LINE__, addr);
84 return (NULL);
85 }
86
87 service = (SERVICE*) acl_mycalloc(1, sizeof(SERVICE));
88 ACL_SAFE_STRNCPY(service->listen_addr,
89 addr, sizeof(service->listen_addr));
90 ACL_SAFE_STRNCPY(service->dns_ip, dns_ip, sizeof(service->dns_ip));
91 service->dns_port = dns_port;
92 snprintf(service->dns_addr, sizeof(service->dns_addr),
93 "%s:%d", dns_ip, dns_port);
94 service->conn_timeout = 10;
95 service->rw_timeout = 10;
96
97 service->table = acl_htable_create(100, 0);
98 service->aio = acl_aio_create(ACL_EVENT_SELECT);
99 service->sstream = acl_aio_open(service->aio, sstream);
100 acl_aio_ctl(service->sstream, ACL_AIO_CTL_ACCEPT_FN, accept_callback,
101 ACL_AIO_CTL_CTX, service, ACL_AIO_CTL_END);
102
103 acl_aio_accept(service->sstream);
104 service_udp_init(service, local_ip, local_port, dns_ip, dns_port);
105 return (service);
106}
107
108void service_free(SERVICE *service)
109{

Callers 1

initFunction · 0.70

Calls 8

acl_vstream_listen_exFunction · 0.85
acl_msg_errorFunction · 0.85
acl_htable_createFunction · 0.85
acl_aio_createFunction · 0.85
acl_aio_openFunction · 0.85
acl_aio_ctlFunction · 0.85
acl_aio_acceptFunction · 0.85
service_udp_initFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…