Tag: tcpsocket

Erlang中的tcp_socket行为不一致

为了一次读取输入1个字符,我写了一个使用ssty raw ac程序。 我使用这个character.c程序来调用一个erlang文件, naive_tcp.erl通过socket将消息发送到同一台机器上的监听服务器。 我希望这个服务器naive_tcp2.erl用26行降序整数和80字符长字符串写回2“|” 管道在其中,以便它在80×26终端上排队。 相反,会发生非常不一致的数据打印。 运行./character.c ,然后每隔几秒按键盘上的一个键,你可以看到输出以”26″开头并下降到”1″ ,但你可以看到它下降到”23″ , “21”或仅”24″ 。 character.c: #include #include int main(void){ system (“clear”); int c; /* use system call to make terminal send all keystrokes directly to stdin */ system (“/bin/stty raw”); while((c=getchar())!= ‘.’) { char command[100]; sprintf(command, “erl -noshell -run naive_tcp go -s erlang halt”); system(command); […]