Skip to content

Instantly share code, notes, and snippets.

@Fuyutsubaki
Last active November 16, 2016 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fuyutsubaki/04ac954da79d3d2c23f9a788fda26916 to your computer and use it in GitHub Desktop.
Save Fuyutsubaki/04ac954da79d3d2c23f9a788fda26916 to your computer and use it in GitHub Desktop.
なんか止まる時がある
# include <Siv3D.hpp>
void Main()
{
s3d::TCPServer s;
s3d::TCPClient c;
using LenType = std::uint16_t;
s.startAccept(57913);
c.connect(s3d::IPv4::localhost(), 57913);
while (System::Update())
{
{//send
s3d::String str=LR"(:0123456789)";
LenType len = str.length * sizeof(wchar);
c.send(len);
c.send(str.data(), len);
}
{//recv
LenType len = 0;;
if (s.lookahead(len) && s.available() >= len)
{
s.read(len);
s3d::Array<s3d::uint8> buf(len);
s.read(buf.data(), len);
if (buf[0] != ':')//:のはずなのでここに入ることはない
{
Println(L"warning!!", buf);
}
Print(L".");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment