English 中文(简体)
在Conlin,我如何使用2个方案,后者将案文数据发送到首个使用排版展示的图像?
原标题:In C on Linux, how would I go about using 2 programs, the latter sending text data to the first displayed using stdout?

我在<斯特隆>C>就<号文件>上写了一幅简单的信使节目。

现在 我有一个方案,即:将一个袖珍/strong”列入当地机器上的港口;listens for text data is sent by another program that relevant to my local organ IP and Port.

Well, I can have this client send text data to my program, and have it displayed using stdout on my local machine; however, I cannot program a way to send data back to the client machine, because my program is busy listening and displaying the text sent by the client machine.

我将如何着手建立一个新程序(倾听和展示客户机寄给它的案文,然后采用这一案文,并将其发送到另一个方案<代码>stdout,而另一个方案则负责stdin/code>。 发放给客户机器,或设立两个方案,分别从事工作(发放、接收和展示),并相互发送适当的数据?

Sorry if that is weirdly worded, and I will clarify if need be. I looked into exec, execve, fork, etc. but am confused as to whether this is the appropriate path to look in to, or if there is a simpler way that I am missing.

任何帮助都将受到高度赞赏。 谢谢。

EDIT: In retrospect, I figured that this would be much easier accomplished with 2 separate programs. One, the IM server, and the others, the IM clients.

监文信息系统客户将与监文信息系统服务器方案连接,并将他们希望的任何文本送交监文信息系统服务器。 然后,监文信息系统服务器将只记录在一份缓冲/档案中向它发送的数据,同时记录每个客户寄给它的案文所附客户的姓名/顺序,并将该文本(以姓名:正文形式)发送给每个客户。

这将不再需要对<代码>stdin stdout进行复杂的过程/program通信,而则使用简单的客户/服务器通信,客户方案显示通过<代码>stdout向服务器发送的案文,并利用stdin/code>向服务器发送任何文本。

尽管如此,我仍然有兴趣回答我原来的问题:科学。 感谢大家阅读,希望有人将受益于我的思想集思广益,或来自社区的任何答案。

最佳回答

然而,我无法规划向客户机器发送数据的方法,因为我的方案忙于听取和展示客户机器发送的文本。

由<条码>accept()从倾听材料中归还的同一袖珍可用于发送和接收数据。 因此,你们的袖珍永远不会因为你重新阅读而成为“虚伪的”。

如果需要同时阅读和书写,则在两个不同的路面上分享从<条码>accept()中回收的袖珍。 由于网络中正在利用两个不同的缓冲器发送和接收袖珍材料,因此,专用读物和另一个专用读书读物无需使用自动交换机。

问题回答

我要谈谈k(k)(一)——建立一个儿童进程,现在,你有两个不同的进程,可以在两个不同的议事日程上做两个不同的事——一个可以接收,另一个可以发送。 我没有像现在这样把客户/服务者 co在一起的个人经验,但这将是我解决你问题的第一个表象。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...