如何实现不挂起UI的格式友好的TCP服务器. [英] How to implement a form friendly TCP server that doesn't hang the UI.

查看:57
本文介绍了如何实现不挂起UI的格式友好的TCP服务器.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对此的要求基于以下内容:-

The requirements for this are based on the following:-

我目前正在为GTAV编写一个mod,该mod实现了整个城市的全程公交服务.为此,我正在编写一个winforms应用程序,该程序可让我计划要使用的Mod的时间表和公交路线.我也想做的是 使用同一个伴侣应用程序作为一种物流查看器,使我可以在游戏运行时监视,跟踪和跟踪服务中的任何公交车.

I am currently writing a mod for GTAV that implements a fully scheduled bus service throughout the city. To work with that, I am writing a winforms app that allows me to plan schedules and bus routes for the mod to use. What I also want to do though, is use that same companion app to be a kind of logistics viewer, that allows me to monitor, track and follow any of the buses in service, while the game is running.

我计划在另一台计算机上运行该程序,我可以使用另外两台PC,但是在一切运行时,我仍然需要能够与表单进行交互和操作.我尝试过的每个TCP服务器示例都完全束缚了UI,因为 它们似乎被设计为在控制台应用程序中运行,该控制台应用程序除了处理连接外什么也不做.我的应用程序必须主要是可正常运行的winform应用程序,该应用程序还应将服务器/客户端通信作为辅助功能来处理.我看过之后的例子 例如,尝试代码和类直到它们从我耳边流血,并且它们都具有相同的最终结果...一个无响应的UI.

I plan to run this programme on a different machine, I have two other PCs that I can use, but I still need to be able to interact with and manipulate the form while everything is running. Every TCP server example I have tried, completely ties up the UI because they seem to be designed to run in a console application that just does nothing but handle connections. My app needs to be primarily a functioning winform app, that also handles server/client communication as a secondary feature. I have looked at example after example, tried code and classes till they bleed from my ears, and they all have the same end result... a UI that responds to nothing.

现在,我知道大多数人准备添加的解决方案是了解异步通信,线程等...,并且我已经诚实地尝试过.在我这样的年龄和目前的思想状态下,我似乎无法设法接受和接受.外推 我一直在阅读大量的技术术语,以获取所需的信息.需要说明的是,我不是一个新手,我从80年代初期就开始在ZX81和汇编器中使用Z80、6502、8086和68000以来,就一直在编写软件.我只是在挣扎 以我目前的心态接受信息,所以我只是在寻找关于我应该使用哪种方法的更加用户友好的指针.我从未使用过任何类型的网络或多线程,这对我没有帮助.我的C#程序通常是 标准的基于UI的utils,或在使用XNA时与游戏相关的内容.

Now I know the solution most are readying to add, is learn about asynchronous communication, threading etc... and I have honestly tried to do so. At my age and with my current state of mind, I just cannot seem to manage to take in and  extrapolate the required information from the mass of technical jargon I keep reading. Just to be clear, I'm not a newbie coding idiot, I've been writing software since using basic on the ZX81 and assembler in Z80, 6502, 8086 and 68000 in the very early 80's. I am just struggling to take in information in my current state of mind, so am just looking for more user friendly pointers as to which approach I should be using. I have never used any kind of networking or multi-threading, which isn't helpful I know. My C# programmes are usually standard UI based utils, or game related when I was using XNA.

所有服务器必须处理的是通过字符串(优选)或字节的周期性和常规位置/标题数据流.它将只有一个客户端连接,这将是运行在GTAV游戏中的mod(已经在运行) 很好,包括客户端代码.

All the server has to handle, is periodic and regular streams of location/heading data via either string (preferable) or bytes. It will only ever have a single client connection, and that will be the mod running inside the GTAV game (which is already working fine, including the client side code).

任何人都可以提供任何帮助/指示器等吗?

Can anyone offer any assistance/pointers etc...?

Worms Forts 10/10,MotoGP3 10/10,Worms 10/10,Rogue Trooper 10/10-谢谢Total Mobile:D

Worms Forts 10/10, MotoGP3 10/10, Worms 10/10, Rogue Trooper 10/10 - Thank you Total Mobile :D

推荐答案

你好,

 这里是一个链接,为使用Socket的客户端和服务器提供详细信息和代码示例.我

 Here is a link that provides details and code sample for client and server using Sockets. I

认为这将很有用.当然,如果您遇到问题,请务必回来,以便我们

think this will be useful. Of course if you have issues then please do come back so we can

进一步帮助您

MSDN帮助

https://msdn.microsoft.com/zh-cn/library/windows/desktop/ms737889%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

https://msdn.microsoft.com/en-us/library/windows/desktop/ms737889%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

C尖锐讨论

  http://codereview.stackexchange.com/questions/24758/tcp-async-socket-server-client-communication

 http://codereview.stackexchange.com/questions/24758/tcp-async-socket-server-client-communication

祝你好运! :)

注意:我很抱歉为C ++和C#提供代码参考.

NOTE: My apologies for the code reference for C++ and C#.


这篇关于如何实现不挂起UI的格式友好的TCP服务器.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆