SimpleSocket  0.1
Some wrappers that make using sockets easier in C++
swrappers.hh
Go to the documentation of this file.
1 #pragma once
2 #include <boost/utility/string_ref.hpp>
3 
4 #include "comboaddress.hh"
5 
61 int SSocket(int family, int type, int flags=0);
64 int SConnect(int sockfd, const ComboAddress& remote);
66 int SBind(int sockfd, const ComboAddress& local);
67 
69 int SAccept(int sockfd, ComboAddress& remote);
70 
72 int SListen(int sockfd, int limit);
73 
75 int SSetsockopt(int sockfd, int level, int opname, int value);
76 
78 void SWrite(int sockfd, boost::string_ref content, std::string::size_type* wrlen=0);
79 
80 std::string SRead(int sockfd, std::string::size_type limit = std::numeric_limits<std::string::size_type>::max());
81 
83 void SetNonBlocking(int sockfd, bool to=true);
84 
86 std::vector<ComboAddress> resolveName(boost::string_ref name, bool ipv4=true, bool ipv6=true);
87 
Definition: comboaddress.hh:78
void SWrite(int sockfd, boost::string_ref content, std::string::size_type *wrlen=0)
Attempt to write string to the socket. Partial write is an exception if &#39;wrlen&#39; not set...
Definition: swrappers.cc:68
int SBind(int sockfd, const ComboAddress &local)
Bind a socket. Error = exception.
Definition: swrappers.cc:32
int SSocket(int family, int type, int flags=0)
Create a socket. Error = exception.
Definition: swrappers.cc:14
int SListen(int sockfd, int limit)
Enable listen on a socket. Error = exception.
Definition: swrappers.cc:52
int SAccept(int sockfd, ComboAddress &remote)
Accept a new connection on a socket. Error = exception.
Definition: swrappers.cc:42
int SSetsockopt(int sockfd, int level, int opname, int value)
Set a socket option. Error = exception.
Definition: swrappers.cc:60
std::vector< ComboAddress > resolveName(boost::string_ref name, bool ipv4=true, bool ipv6=true)
Use system facilities to resolve a name into addresses. If no address found, returns empty vector...
Definition: swrappers.cc:116
int SConnect(int sockfd, const ComboAddress &remote)
Connect a socket. Error = exception.
Definition: swrappers.cc:22
void SetNonBlocking(int sockfd, bool to=true)
Set a socket to (non) blocking mode. Error = exception.
Definition: swrappers.cc:99