Update socket send,recv interface.

Marco defined instead of pragma once now.
This commit is contained in:
Kirigaya Kazuto 2018-02-11 15:41:52 +08:00
parent 14f0bb0f2f
commit 579036b63e
2 changed files with 10 additions and 9 deletions

View File

@ -168,14 +168,14 @@ int sock::connect(const std::string& IPStr,int Port)
return ::connect(sfd,(sockaddr*)&saddr,sizeof(saddr));
}
int sock::send(const char* Buffer,int Length)
int sock::send(const void* Buffer,int Length)
{
return ::send(_pp->sfd,Buffer,Length,0);
return ::send(_pp->sfd,(const char*)Buffer,Length,0);
}
int sock::recv(char* Buffer,int MaxToRecv)
int sock::recv(void* Buffer,int MaxToRecv)
{
return ::recv(_pp->sfd,Buffer,MaxToRecv,0);
return ::recv(_pp->sfd,(char*)Buffer,MaxToRecv,0);
}
int sock::getsendtime(int& _out_Second, int& _out_uSecond)

11
gsock.h
View File

@ -3,9 +3,8 @@
* Licensed under MIT
*/
/** Version: 2.2 Update: 20170815*/
#pragma once
#ifndef _gsock_h
#define _gsock_h
#include <cstdint>
#include <string>
@ -35,8 +34,8 @@ public:
/// Return:
/// return what send() and recv() call returns.
int send(const char* Buffer,int Length);
int recv(char* Buffer,int MaxToRecv);
int send(const void* Buffer,int Length);
int recv(void* Buffer,int MaxToRecv);
int getsendtime(int& _out_Second,int& _out_uSecond);
int getrecvtime(int& _out_Second,int& _out_uSecond);
@ -87,3 +86,5 @@ private:
/// Net Tools
int DNSResolve(const std::string& HostName,std::string& _out_IPStr);
#endif // _gsock_h