0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C++ Builder > TClientSocketを使った送信例

Last updated at Posted at 2016-12-27
動作環境
C++ Builder XE4
Windows 7 Pro: 送信元
Windows 10 Pro: 送信先

TClientSocket を使った送信の例。

Unit1.cpp
void __fastcall TMainForm::debugB_tcpClick(TObject *Sender)
{
	char zbuf[20] = {0};
	ClientSocket->Host = "192.168.2.7";
	ClientSocket->Port = 2000;
	ClientSocket->Open();

	for(int loop=0; loop<3; loop++) {
		Application->ProcessMessages();
		Sleep(300);
	}

	strcpy(zbuf, "TEST");
	ClientSocket->Socket->SendBuf(&zbuf[0], strlen(zbuf));

	Application->ProcessMessages();
	Sleep(300);

   	ClientSocket->Close();
}

送信先(IP:192.168.2.7)には以下のツールを使わせていただきました。
どうもありがとうございます。
TCP/IPテストツール by のんさん

結果

qiita.png

一応動いたが、Sleep()処理などはきちんとは検討していない。

備考

TClientSocketを今後使うことはないだろうが、過去のソフトの不具合対策にその振る舞いを確認しないといけない、と理由から今回調べた。

関連: C++ Builder > TClientSocket の情報 > インストール / 非推奨かどうか / 代替案

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?