SpiecsEngine
 
Loading...
Searching...
No Matches

◆ StartClient()

static void SpicesTest::BufferTest::StartClient ( Spices::Net::InetAddress & address)
inlinestatic

Create Client.

Parameters
[in]addressClient address.

Definition at line 58 of file Buffer_test.h.

59 {
60 Spices::Net::Socket clientSocket;
61 clientSocket.Create();
62
63 clientSocket.Connect(&address);
64
66 int error;
67 for (int i = 0; i < 100; i++)
68 {
69 std::stringstream ss0;
70 ss0 << "Hello Client! " << i;
71
72 buffer.Append(ss0.str());
73 buffer.WriteFd(clientSocket.Fd(), &error);
74 buffer.RetrieveAll();
75
76 std::stringstream ss1;
77 ss1 << "Hello Server! " << i;
78 buffer.ReadFd(clientSocket.Fd(), &error);
79
80 EXPECT_STREQ(buffer.RetrieveAllAsString().c_str(), ss1.str().c_str());
81 }
82 }
std::string RetrieveAllAsString()
Get readable area data as string.
Definition Buffer.h:96
size_t WriteFd(SOCKET fd, int *saveErrno) const
Write to Socket.
Definition Buffer.cpp:72
size_t ReadFd(SOCKET fd, int *saveErrno)
Read from Socket.
Definition Buffer.cpp:53
void RetrieveAll()
Retrieve all buffer data.
Definition Buffer.h:87
void Append(const std::string &msg)
Append Message to this buffer.
Definition Buffer.cpp:41
Wrapper of readwrite buffer.
Definition Buffer.h:19
void Connect(InetAddress *connectAddress) const
Connect to socket.
Definition Socket.cpp:62
void Create()
Create Non Blocking Socket.
Definition Socket.cpp:27
const SOCKET Fd() const
Get this socket fd.
Definition Socket.h:60
This class is Wrapper of socket.
Definition Socket.h:18

References Spices::Net::Socket::Connect(), Spices::Net::Socket::Create(), and Spices::Net::Buffer::RetrieveAll().

Referenced by SpicesTest::TEST().