简体   繁体   English

我如何在此程序中使用socket.send方法?

[英]how do i use socket.send method in this program?

I have written this code to search for a string from a file. 我已编写此代码以从文件中搜索字符串。 Since this program cannot be used for multiple clients, i was asked to make it more robust by using socket. 由于该程序不能用于多个客户端,因此有人要求我使用套接字使其更强大。 I want to know where and how socket could be used in this program.. I'm still learning about sockets.. Couldn't exactly figure out where and how exactly it could be used.. Could someone just help me with it? 我想知道在该程序中可以在哪里使用套接字以及如何使用它。.我仍在学习套接字..无法确切地弄清楚它可以在哪里使用以及如何被完全使用..有人可以帮助我吗? This is my program.. 这是我的程序

class Program { 课程计划{

    static void Main(string[] args)
    {
        if (File.Exists("C://myfile2.txt"))
        {
            var text = File.ReadAllText("C://myfile2.txt");


            foreach (var word in new[] { "and", "so", "not", "c", "to", "by", "has", "do", "behavior", "dance", "france", "ok","that", "please","hello","system","possible","impossible","absolutely","sachin","bradman","schumacher","http","console","application" })
            {
                var w = word;

                new Thread(() => Console.WriteLine("{0}: {1}", w, text.Contains(w) ? "Present" : "Not Present")).Start();
            }

        }
        else
            Console.WriteLine("File Does not exist");
        Console.ReadLine();
    }

}

Allright, You should create a client server app with a tcp connection. 好了,您应该使用tcp连接创建一个客户端服务器应用程序。 Here is a tutorial how that works. 是一个如何工作的教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM