Revision e16669a8 ml.c
ml.c | ||
---|---|---|
1180 | 1180 |
|
1181 | 1181 |
|
1182 | 1182 |
/* |
1183 |
* returns a handle to the socketID struct the ipaddr can be a null
|
|
1183 |
* returns the file descriptor, or <0 on error. The ipaddr can be a null
|
|
1184 | 1184 |
* pointer. Then all available ipaddr on the machine are choosen. |
1185 | 1185 |
*/ |
1186 |
void create_socket(const int port, const char *ipaddr)
|
|
1186 |
int create_socket(const int port, const char *ipaddr)
|
|
1187 | 1187 |
{ |
1188 | 1188 |
struct sockaddr_in udpaddr; |
1189 | 1189 |
udpaddr.sin_family = AF_INET; |
... | ... | |
1208 | 1208 |
local_socketID.internal_addr = udpgen; |
1209 | 1209 |
|
1210 | 1210 |
socketfd = createSocket(port, ipaddr); |
1211 |
if (socketfd < 0){ |
|
1212 |
return socketfd; |
|
1213 |
} |
|
1211 | 1214 |
|
1212 | 1215 |
struct event *ev; |
1213 | 1216 |
ev = event_new(base, socketfd, EV_READ | EV_PERSIST, recv_pkg, NULL); |
... | ... | |
1215 | 1218 |
event_add(ev, NULL); |
1216 | 1219 |
|
1217 | 1220 |
try_stun(); |
1221 |
|
|
1222 |
return socketfd; |
|
1218 | 1223 |
} |
1219 | 1224 |
|
1220 | 1225 |
/* |
... | ... | |
1254 | 1259 |
|
1255 | 1260 |
/**************************** MONL functions *************************/ |
1256 | 1261 |
|
1257 |
void mlInit(bool recv_data_cb,struct timeval timeout_value,const int port,const char *ipaddr,const int stun_port,const char *stun_ipaddr,receive_localsocketID_cb local_socketID_cb,void *arg){
|
|
1262 |
int mlInit(bool recv_data_cb,struct timeval timeout_value,const int port,const char *ipaddr,const int stun_port,const char *stun_ipaddr,receive_localsocketID_cb local_socketID_cb,void *arg){
|
|
1258 | 1263 |
|
1259 | 1264 |
base = (struct event_base *) arg; |
1260 | 1265 |
recv_data_callback = recv_data_cb; |
... | ... | |
1265 | 1270 |
|
1266 | 1271 |
} |
1267 | 1272 |
register_recv_localsocketID_cb(local_socketID_cb); |
1268 |
create_socket(port, ipaddr); |
|
1269 |
|
|
1273 |
return create_socket(port, ipaddr); |
|
1270 | 1274 |
} |
1271 | 1275 |
|
1272 | 1276 |
/* register callbacks */ |
Also available in: Unified diff