Skip to content

Commit

Permalink
Merge pull request #55 from cookiengineer/feature/port
Browse files Browse the repository at this point in the history
(int) APE_socket_port(socket) implementation
  • Loading branch information
paraboul authored Apr 24, 2017
2 parents 611d48d + cd8125d commit 2a8998d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ape_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,17 @@ int APE_socket_write(ape_socket *socket, void *data, size_t len,
return 0;
}

uint16_t APE_socket_port(ape_socket *socket)
{
if (!socket) {
return 0;
}


return ntohs(socket->sockaddr.sin_port);

}

char *APE_socket_ipv4(ape_socket *socket)
{
if (!socket) {
Expand Down
1 change: 1 addition & 0 deletions src/ape_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ int APE_socket_writev(ape_socket *socket, const struct iovec *iov, int iovcnt);
int APE_sendfile(ape_socket *socket, const char *file);
int APE_socket_is_online(ape_socket *socket);

uint16_t APE_socket_port(ape_socket *socket);
char *APE_socket_ipv4(ape_socket *socket);

int ape_socket_destroy(ape_socket *socket);
Expand Down
1 change: 1 addition & 0 deletions tests/unittest_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
//@TODO: void APE_socket_shutdown(ape_socket *socket);
//@TODO: void APE_socket_shutdown_now(ape_socket *socket);
//@TODO: int APE_sendfile(ape_socket *socket, const char *file);
//@TODO: int APE_socket_port(ape_socket *socket);
//@TODO: char *APE_socket_ipv4(ape_socket *socket);
//@TODO: int APE_socket_is_online(ape_socket *socket)
//@TODO: int ape_socket_do_jobs(ape_socket *socket);
Expand Down

0 comments on commit 2a8998d

Please sign in to comment.