mirror of
https://github.com/vale981/ray
synced 2025-03-14 07:06:38 -04:00
14 lines
293 B
C++
14 lines
293 B
C++
![]() |
#include "net.h"
|
||
|
|
||
|
#include "common.h"
|
||
|
|
||
|
int parse_ip_addr_port(const char *ip_addr_port, char *ip_addr, int *port) {
|
||
|
char port_str[6];
|
||
|
int parsed = sscanf(ip_addr_port, "%15[0-9.]:%5[0-9]", ip_addr, port_str);
|
||
|
if (parsed != 2) {
|
||
|
return -1;
|
||
|
}
|
||
|
*port = atoi(port_str);
|
||
|
return 0;
|
||
|
}
|