小编sun*_*pol的帖子

使用线程管道通信

我有两个可执行文件:client.exeserver.exe.

它们通过使用命名管道相互通信.当服务器仅侦听客户端请求并向客户端发送响应时,它们可以正常工作.

但现在要求是exes包含客户端管道和服务器管道.所以每个exe包含两个方法:serverpipe()clientpipe().这些方法在一个线程中,不相互通信.

第一个客户端和服务器正常通信

Client.EXE:

public static void Main(string[] Args)
{
    PipeClient obj=new PipeClient();
    obj.client();
    Thread startserver = new Thread(new ThreadStart(obj.server));
    startserver.Start();
}

public void client()
{
    int cnt =0;
    while (true)
    {
       System.IO.Pipes.NamedPipeClientStream pipeClient = new System.IO.Pipes.NamedPipeClientStream(".", "\\\\.\\pipe\\SamplePipe1", System.IO.Pipes.PipeDirection.InOut, System.IO.Pipes.PipeOptions.None);

        if (pipeClient.IsConnected != true) { pipeClient.Connect(); }

        StreamReader sr = new StreamReader(pipeClient);
        StreamWriter sw = new StreamWriter(pipeClient);

        string temp;
        temp = sr.ReadLine();

        if (temp == "Waiting")
        {
            try
            { …
Run Code Online (Sandbox Code Playgroud)

c# ipc named-pipes

0
推荐指数
1
解决办法
4402
查看次数

将vb.net转换为vb6

我已经在c#和vb.net中编写了代码,但现在要求是vb6.Can我将vb.net代码转换为vb6.如何在vb6中添加命名空间System.Security.Cryptography

vb.net vb6

0
推荐指数
1
解决办法
3788
查看次数

标签 统计

c# ×1

ipc ×1

named-pipes ×1

vb.net ×1

vb6 ×1