Added some socket functions
This commit is contained in:
@ -960,6 +960,9 @@
|
||||
/* Define if pthread_t is signed */
|
||||
#undef QSE_PTHREAD_T_IS_SIGNED
|
||||
|
||||
/* Define if sa_family_t is signed */
|
||||
#undef QSE_SA_FAMILY_T_IS_SIGNED
|
||||
|
||||
/* sizeof(char) */
|
||||
#undef QSE_SIZEOF_CHAR
|
||||
|
||||
@ -1104,6 +1107,9 @@
|
||||
/* The size of `pthread_t', as computed by sizeof. */
|
||||
#undef SIZEOF_PTHREAD_T
|
||||
|
||||
/* The size of `sa_family_t', as computed by sizeof. */
|
||||
#undef SIZEOF_SA_FAMILY_T
|
||||
|
||||
/* The size of `short', as computed by sizeof. */
|
||||
#undef SIZEOF_SHORT
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
||||
class AppRoot: Uncopyable, public Types, public Mmged
|
||||
class AppRoot: public Uncopyable, public Types, public Mmged
|
||||
{
|
||||
public:
|
||||
AppRoot (Mmgr* mmgr): Mmged(mmgr), _root_only(false) {}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#ifndef _QSE_SI_SOCKET_HPP_
|
||||
#define _QSE_SI_SOCKET_HPP_
|
||||
|
||||
#include <qse/Types.hpp>
|
||||
#include <qse/Uncopyable.hpp>
|
||||
#include <qse/si/SocketAddress.hpp>
|
||||
#include <qse/si/sck.h>
|
||||
|
||||
@ -34,20 +36,41 @@
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
|
||||
class Socket
|
||||
class Socket: public Uncopyable, public Types
|
||||
{
|
||||
public:
|
||||
enum ErrorCode
|
||||
{
|
||||
E_NOERR,
|
||||
E_NOMEM,
|
||||
E_INVAL,
|
||||
E_NOTOPEN,
|
||||
E_SYSERR
|
||||
};
|
||||
|
||||
Socket () QSE_CPP_NOEXCEPT;
|
||||
~Socket () QSE_CPP_NOEXCEPT;
|
||||
|
||||
void setError (ErrorCode error_code, const qse_char_t* fmt = QSE_NULL, ...);
|
||||
|
||||
|
||||
int open (int domain, int type, int protocol) QSE_CPP_NOEXCEPT;
|
||||
void close () QSE_CPP_NOEXCEPT;
|
||||
|
||||
int connect (const SocketAddress& target) QSE_CPP_NOEXCEPT;
|
||||
int beginConnect (const SocketAddress& target) QSE_CPP_NOEXCEPT;
|
||||
int bind (const SocketAddress& target) QSE_CPP_NOEXCEPT;
|
||||
int accept (Socket* newsck, SocketAddress* newaddr, int flags) QSE_CPP_NOEXCEPT;
|
||||
|
||||
int read () QSE_CPP_NOEXCEPT;
|
||||
int write () QSE_CPP_NOEXCEPT;
|
||||
|
||||
protected:
|
||||
qse_sck_hnd_t handle;
|
||||
|
||||
ErrorCode errcode;
|
||||
qse_char_t errmsg[128];
|
||||
|
||||
void set_error_with_syserr (int syserr);
|
||||
};
|
||||
|
||||
|
||||
|
@ -41,7 +41,6 @@ public:
|
||||
SocketAddress (int family);
|
||||
SocketAddress (const qse_skad_t* skad);
|
||||
SocketAddress (const qse_nwad_t* nwad);
|
||||
SocketAddress (const struct sockaddr* ptr, int len);
|
||||
|
||||
int getFamily () const;
|
||||
|
||||
@ -68,7 +67,6 @@ public:
|
||||
|
||||
int set (const qse_skad_t* skad);
|
||||
int set (const qse_nwad_t* nwad);
|
||||
int set (const struct sockaddr* ptr, int len); // treat ptr as a pointer to struct sockaddr
|
||||
|
||||
protected:
|
||||
qse_skad_t skad;
|
||||
|
Reference in New Issue
Block a user