質問するログイン新規登録

質問編集履歴

1

テスト履歴について追記、動作についてコメントを追記

2021/12/25 03:14

投稿

Maitz.
Maitz.

スコア12

title CHANGED
File without changes
body CHANGED
@@ -107,6 +107,7 @@
107
107
 
108
108
  Window::SetTitle(U"TCPClient: Waiting for connection...");
109
109
 
110
+ //IP入力用テキストボックス
110
111
  TextEditState te0;
111
112
  TextEditState te1;
112
113
  te1.text = U"Siv3D"; // デフォルトの文字列
@@ -120,6 +121,7 @@
120
121
  {
121
122
  const Point clientPlayerPos = Cursor::Pos();
122
123
 
124
+ //IP入力用テキストボックス
123
125
  SimpleGUI::TextBox(te0, Vec2{ 100, 140 });
124
126
  SimpleGUI::TextBox(te1, Vec2{ 100, 200 });
125
127
  SimpleGUI::TextBox(te2, Vec2{ 100, 260 });
@@ -127,12 +129,14 @@
127
129
 
128
130
  if (SimpleGUI::Button(U"invite", Vec2{ 420, 200 }))
129
131
  {
132
+ //ボタンが押された時、一旦通信切断
130
133
  client.disconnect();
131
134
 
132
135
  connected = false;
133
136
 
134
137
  Window::SetTitle(U"TCPClient: Waiting for connection...");
135
138
 
139
+ //テキストボックスから文字列取得、数値型で仮保持。
136
140
  //const String s = te1.text;
137
141
  //std::string str = s.narrow();
138
142
  //ip = inet_addr(str.c_str());
@@ -141,6 +145,7 @@
141
145
  int32 num_c = ParseOr<int32>(te2.text, 10);
142
146
  int32 num_d = ParseOr<int32>(te3.text, 10);
143
147
 
148
+ //IP変数に代入して、接続を再試行
144
149
  ip = IPv4Address::IPv4Address(num_a, num_b, num_c, num_d);
145
150
  // 接続を再試行
146
151
  client.connect(ip, port);
@@ -198,7 +203,10 @@
198
203
  ### 試したこと
199
204
  >ここに問題に対して試したことを記載してください。
200
205
 
206
+ サンプルプログラムは同一pc上で通信する仕様で、想定通り動作しました。
207
+ 次に改造したプログラムを同一pc上でテストしました。「IPv4Address::Localhost();の代入」「手動の"127.0.0.1"代入」「関係ないアドレスでのエラーチェック」いずれも想定通り動作しました。
208
+
201
- 上記のプログラムを2つのpcにて実行。
209
+ その後上記のプログラムを2つのpcにて実行。
202
210
  サーバー側のpcで「ipconfig」を実行し、イーサネットのIPv4アドレスを特定。
203
211
  クライアント側で入力したところ、接続できず。
204
212