シナリオは次のとおりです。
Linux で telnet ユーティリティを使用してサーバーに接続します。接続が確立された後、クライアントは、サーバーによって読み取られる引数を入力する必要があります。
サーバーコードは次のとおりです。
int main(void)
{
int new_fd;
char *string;
// Establish the connection
if (send(new_fd, "Enter Command: ", 15, 0) == -1)
perror("send");
// Here I want to accept the argument from the server
return 0;
}
次を使用してサーバーに telnet 接続すると、 telnet servername portnumber
client receive :Enter Command:
の前に引数を入力します。例えばEnter Command: Hey There!
私がしたいのは、Hey There!
それをstring
サーバーに保存して印刷することだけです。どうやってやるの?