Creating a WiFi application

给你一囗甜甜゛ 提交于 2019-12-21 20:19:31

问题


I have to write an Application which shares data over an Wireless Ad Hoc Network.

And I have No Idea how to do this. I am good at C# so I am thinking to choose C# for writting the Application

First question- How to read Data Received over WiFi or How to send Data over WiFi... Means is there any Port to which I should Read/Write?

Second Question- All the Protocol Management stuff is done by Adapter or my Application should that?

And also suggest some reading which I should go for! I read basics of WiFi and how it works and all!

Regards!


回答1:


You need to start reading about Native Wifi for Windows XP SP3/Win2k/Vista/7.




回答2:


1.you can use socket programming and get/send data with this code.

            public void get_data_from_server()
                    {
                        try
                        {
                            while (true)
                        {

                                byte[] b = new byte[1024];
                                int r = SocClient.Receive(b);
                                if (r > 0)
                                {
                                    this.Invoke((MethodInvoker)delegate
                                    {
                                        listBoxclient.Items.Add(Encoding.Unicode.GetString(b, 0, r));
                                        sock.Text = "socket_client == Connected";
                                        sock.ForeColor = Color.Green;
                                    });
                                }

                            Thread.Sleep(400);
                            }


                        }
                        catch
                        {

                            ;


                        }
                    }

                private void sending_client_to_server()
                    {
                        try
                        {
                            while (true)
                            {
                                string datetime = gettime();
                               string ipee =get_ip_address();
                                byte[] b = Encoding.Unicode.GetBytes(ipee + " : " + "5050" + "  " + datetime);
                                SocClient.Send(b);
                                delay();
                                Thread.Sleep(400);
                            }
                        }
                        catch
                        {
                            ;
                        }
                    }

2.you can use TCP or UDP and do this.

3.you must read socket programing in C#



来源:https://stackoverflow.com/questions/4497557/creating-a-wifi-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!