+ecore_con_client_port_get

SVN revision: 56950
This commit is contained in:
Mike Blumenkrantz 2011-02-11 07:38:27 +00:00
parent d0ac8d8601
commit 276eccb1bf
3 changed files with 25 additions and 1 deletions

View File

@ -30,3 +30,7 @@
* Unify event handler code
* Always increment server event count for client events
2011-02-11 Mike Blumenkrantz
* Added ecore_con_client_port_get

View File

@ -485,6 +485,7 @@ EAPI double ecore_con_client_uptime_get(Ecore_Con_Client *cl);
EAPI double ecore_con_client_timeout_get(Ecore_Con_Client *cl);
EAPI void ecore_con_client_timeout_set(Ecore_Con_Client *cl, double timeout);
EAPI Eina_Bool ecore_con_client_connected_get(Ecore_Con_Client *cl);
EAPI int ecore_con_client_port_get(Ecore_Con_Client *cl);
/**
* @}

View File

@ -1082,7 +1082,7 @@ ecore_con_client_data_get(Ecore_Con_Client *cl)
}
/**
* Gets the IP address of a cleint that has connected.
* Gets the IP address of a client that has connected.
*
* @param cl The given client.
* @return A pointer to an internal string that contains the IP address of
@ -1104,6 +1104,25 @@ ecore_con_client_ip_get(Ecore_Con_Client *cl)
return cl->ip;
}
/**
* @brief Return the port that the client has connected to
* @param cl The client
* @return The port that @p cl has connected to, or -1 on error
* Use this function to return the port on which a given client has connected.
*/
EAPI int
ecore_con_client_port_get(Ecore_Con_Client *cl)
{
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_port_get");
return -1;
}
if (cl->client_addr->sa_family == AF_INET)
return ((struct sockaddr_in*)cl->client_addr)->sin_port;
return ((struct sockaddr_in6*)cl->client_addr)->sin6_port;
}
/**
* @brief Check how long a client has been connected
* @param cl The client to check