客户端-没有服务器的客户端通信? [英] Client - client communication without server?
问题描述
我是套接字编程的新手,我需要澄清一些事情.
I am new to socket programming and I need to clarify some things.
两个客户端之间是否需要服务器通信?让我解释一下我的意思:
Do you need a server between two client communication? Let me explain what I mean:
示例1:
- Client1 :服务器,我想与client2通话
- 服务器:没问题.让我们等他发送连接请求
- Client2 :我在这里.我想和client1聊天.
- 服务器:好的,Client1是Client2的IP地址.对于您的Client2,这里是
- Client1: Server, I want to talk with a client2
- Server: No problem. Let's just wait until he sends the request to connect
- Client2: I'm here. I want to talk with client1.
- Server: Okay Client1 here is Client2 IP address. And for you Client2, here is
Client1 IP地址.您现在可以在没有我的情况下互相交谈.
Client1 IP Address. You can now talk to each other without me.
示例2:
- 客户端1:服务器,请向客户端2发送消息:客户端2.您好吗?"
- 服务器:好的,没问题.向client2发送消息
- Client2 :服务器感谢您发送client1的消息.给他回复:嘿,我很好."
- 服务器:正在向客户端1发送消息.
- Client1: Server, please send client2 a message: "Hey client2. How are you?"
- Server: Okay no problem. Sending message to client2
- Client2: Server thanks for sending client1's message. Send him a reply: "Hey, I'm fine."
- Server: Sending message to client1..
所以我的问题是:在遇到两个客户端以在它们之间进行通信之后,您是否需要一台服务器?还是我走在完全错误的轨道上?
So my question is: Do you need a server after you met two clients together to communicate between them? Or I'm on completely wrong track?
其目的在于,我想将非常简单的手机游戏扩展为多人游戏.例如,我想在PACMAN1手机上显示PACMAN2,反之亦然.
The purpose behind this is that I want to expand my very simple mobile game to become a multiplayer. Just for example, I want to show PACMAN2 on PACMAN1 mobile phone and vice versa.
推荐答案
是的,您可以与不需要任何中央服务器的对等通信进行通信,或者也可以使用sockect或可以与用户ip地址进行通信.
yes, you can do with peer to peer communication does not need any central server or you can also use sockect or you can communicate with user ip address.
参考点对点
这篇关于客户端-没有服务器的客户端通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!