Last active
November 16, 2016 15:56
-
-
Save Fuyutsubaki/04ac954da79d3d2c23f9a788fda26916 to your computer and use it in GitHub Desktop.
なんか止まる時がある
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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