change typedef
This commit is contained in:
@@ -5,25 +5,26 @@ using namespace std;
|
||||
|
||||
// use pthread rw_lock to lock db so you can safy clone .db file
|
||||
|
||||
// When a new client connected:
|
||||
void call(int sock, sockaddr_in newSocketInfo)
|
||||
{
|
||||
std::cout << "new User" << std::endl;
|
||||
char tempBuffer[AS_DEFAULT_BUFFER_SIZE + 1];
|
||||
ssize_t messageLength;
|
||||
while ((messageLength = TcpSocket::recvt(sock, tempBuffer, AS_DEFAULT_BUFFER_SIZE)) > 0)
|
||||
{
|
||||
tempBuffer[messageLength] = '\0';
|
||||
TcpSocket::sendt(sock, tempBuffer, messageLength);
|
||||
}
|
||||
std::cout << "del USER" << std::endl;
|
||||
TcpSocket::closet(sock);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// When a new client connected:
|
||||
TcpSocket::OnNewConnectionCallBack onNewConnection = [](int sock, sockaddr_in newSocketInfo)
|
||||
{
|
||||
std::cout << "new User" << std::endl;
|
||||
char tempBuffer[AS_DEFAULT_BUFFER_SIZE + 1];
|
||||
ssize_t messageLength;
|
||||
while ((messageLength = TcpSocket::recvt(sock, tempBuffer, AS_DEFAULT_BUFFER_SIZE)) > 0)
|
||||
{
|
||||
tempBuffer[messageLength] = '\0';
|
||||
TcpSocket::sendt(sock, tempBuffer, messageLength);
|
||||
}
|
||||
std::cout << "del USER" << std::endl;
|
||||
TcpSocket::closet(sock);
|
||||
};
|
||||
|
||||
// Bind the server to a port.
|
||||
int err = TcpSocket::listent("0.0.0.0", 8888, onNewConnection);
|
||||
int err = TcpSocket::listent("0.0.0.0", 8888, call);
|
||||
if (err < 0)
|
||||
{
|
||||
printf("ERROR %d", err);
|
||||
|
Reference in New Issue
Block a user