No need to save the state of errno
We don't have any library calls afterwards, so it's fine.
This commit is contained in:
parent
6cc7de6383
commit
2dcdf5b74e
@ -33,20 +33,19 @@ int NeoComm_bind(const unsigned short port) {
|
|||||||
struct sockaddr_in serv_addr;
|
struct sockaddr_in serv_addr;
|
||||||
|
|
||||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
int errsv = errno;
|
|
||||||
if(sockfd < 0)
|
if(sockfd < 0)
|
||||||
{
|
{
|
||||||
if(errsv == EACCES)
|
if(errno == EACCES)
|
||||||
NeoComm_error("Insufficient privileges");
|
NeoComm_error("Insufficient privileges");
|
||||||
else if(errsv == ENOBUFS)
|
else if(errno == ENOBUFS)
|
||||||
NeoComm_error("Insufficient resources available");
|
NeoComm_error("Insufficient resources available");
|
||||||
else if(errsv == ENOMEM)
|
else if(errno == ENOMEM)
|
||||||
NeoComm_error("Insufficient memory to open socket");
|
NeoComm_error("Insufficient memory to open socket");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char error_msg[128];
|
char error_msg[128];
|
||||||
snprintf(error_msg, 128, "Failed to initiate socket with errno `%d'",
|
snprintf(error_msg, 128, "Failed to initiate socket with errno `%d'",
|
||||||
errsv);
|
errno);
|
||||||
NeoComm_error(error_msg);
|
NeoComm_error(error_msg);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -57,7 +56,6 @@ int NeoComm_bind(const unsigned short port) {
|
|||||||
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
||||||
if(bind(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) < 0)
|
if(bind(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) < 0)
|
||||||
{
|
{
|
||||||
/*int errsv = errno;*/
|
|
||||||
// TODO: Handle all these errors and shit, I'm too lazy right now
|
// TODO: Handle all these errors and shit, I'm too lazy right now
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user