Skip to content

Commit

Permalink
APE_socket_port(socket) implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
cookiengineer committed Apr 19, 2017
1 parent a1e9d4b commit 1d51148
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ape_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,19 @@ int APE_socket_write(ape_socket *socket, void *data, size_t len,
return 0;
}

int APE_socket_port(ape_socket *socket)
{
if (!socket) {
return -1;
}


int port = ntohs(socket->sockaddr.sin_port);

return 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);

int 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 1d51148

Please sign in to comment.