Skip to content

Commit

Permalink
Merge pull request mfem#4453 from mfem/use-correct-bind
Browse files Browse the repository at this point in the history
use ::bind instead of bind
  • Loading branch information
tzanio authored Aug 27, 2024
2 parents ac2a215 + 7d448fe commit b33a8d2
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions general/isockstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ typedef int socklen_t;
#define close closesocket
#endif

using namespace std;

namespace mfem
{

Expand All @@ -43,7 +41,7 @@ isockstream::isockstream(int port)

if ( (portID = establish()) < 0)
mfem::out << "Server couldn't be established on port "
<< portnum << endl;
<< portnum << std::endl;
Buf = NULL;
}

Expand All @@ -64,7 +62,7 @@ int isockstream::establish()
{
mfem::err << "isockstream::establish(): getaddrinfo() failed!\n"
<< "isockstream::establish(): getaddrinfo() returned: '"
<< myname << "'" << endl;
<< myname << "'" << std::endl;
error = 1;
return (-1);
}
Expand All @@ -74,15 +72,15 @@ int isockstream::establish()
{
if ((sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol)) < 0)
{
mfem::err << "isockstream::establish(): socket() failed!" << endl;
mfem::err << "isockstream::establish(): socket() failed!" << std::endl;
error = 2;
return (-1);
}

int on = 1;
if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
{
mfem::err << "isockstream::establish(): setsockopt() failed!" << endl;
mfem::err << "isockstream::establish(): setsockopt() failed!" << std::endl;
return (-1);
}

Expand All @@ -92,7 +90,7 @@ int isockstream::establish()
if (bind(sfd, rp->ai_addr, rp->ai_addrlen) < 0)
#endif
{
mfem::err << "isockstream::establish(): bind() failed!" << endl;
mfem::err << "isockstream::establish(): bind() failed!" << std::endl;
close(sfd);
error = 3;
continue;
Expand Down Expand Up @@ -152,7 +150,7 @@ void isockstream::receive(std::istringstream **in)

if ((socketID = accept(portID, NULL, NULL)) < 0)
{
mfem::out << "Server failed to accept connection." << endl;
mfem::out << "Server failed to accept connection." << std::endl;
error = 5;
return;
}
Expand All @@ -171,18 +169,18 @@ void isockstream::receive(std::istringstream **in)
Buf = new char[size+1];
if (size != read_data(socketID, Buf, size))
{
mfem::out << "Not all the data has been read" << endl;
mfem::out << "Not all the data has been read" << std::endl;
}
#ifdef DEBUG
else
{
mfem::out << "Reading " << size << " bytes is successful" << endl;
mfem::out << "Reading " << size << " bytes is successful" << std::endl;
}
#endif
Buf[size] = '\0';

close(socketID);
(*in) = new istringstream(Buf);
(*in) = new std::istringstream(Buf);
}

isockstream::~isockstream()
Expand Down

0 comments on commit b33a8d2

Please sign in to comment.