C# 中通过拨号调制解调器在没有互联网的情况下在两台计算机之间建立连接

发布于 2024-09-18 19:06:37 字数 94 浏览 8 评论 0原文

您好,有没有办法在没有互联网的情况下通过拨号调制解调器连接到计算机? 就像windows超级终端一样。 在计算机之间建立连接发送文件。 只需直接连接两台计算机并发送文件即可。

Hi Is there any way to connecting to computers via Dial Modem without internet?
Like windows Hyper terminal.
making connection sending files between computers.
Just Connection Between two Computers Directly and sending FIle.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

呢古 2024-09-25 19:06:37

是的。

假设调制解调器通过串行端口连接(或模拟通过串行端口连接):您需要设置一个调制解调器(了解您的 AT 命令!)来监听和接听来电,另一个拨打第一个。

然后,您可以将这对视为相当长的串行链路。

然而,让一切可靠地工作更像是一门艺术,而不是一门科学,而且如今很少有人做到这一点,以至于很多内容都被遗忘了。我上次以这种方式使用调制解调器已经是十五年前的事了。

Yes.

Assuming the modems are connected via a serial port (or emulate being connected via a serial port): you'll need one modem set up (learn your AT commands!) to listen for and answer incoming calls, and the other to dial the first.

You can then treat the pair as a rather long serial link.

However getting everything to work reliably is more of an art than a science, and something that is so rarely done today that much of it is forgotten. The last time I worked with modems in this way was more than fifteen years ago.

卖梦商人 2024-09-25 19:06:37

过去我们使用的方法是使用零调制解调器电缆。过去,我们甚至曾经以这种方式进行“网络”游戏。

这基本上是一根 RS-232 电缆,接收和发送引脚交叉连接。我仍然看到一些适配器,所以找到一个应该不会太难。

很久以后,一些人创建了SLIP(串行线IP)来使串行线充当整个 TCP/IP 堆栈的载体。稍后,引入了 PPP 作为一项改进。我认为 SLIP 仍然适用于大多数平台,而 PPP 存在于每个可以进行拨号互联网的平台上。

因此,如果问题基本上归结为希望通过 PPP 将两台计算机联网,而不通过其他人的拨号服务器(例如 Earthlink),那么您需要在两台计算机中的一台上安装 PPP 服务器机器。大多数 Linux 发行版都附带它们。对于 Windows,你必须去看看。我愿意帮忙,但我的公司阻碍者又变得过于活跃了。

The way we used to do it back in the olden days was with a null-modem cable. We even used to do "networked" gaming that way, back in the day.

This is bascially an RS-232 cable with the receive and transmit pins crosswired. I still see some adapters around, so it shouldn't be too tough to get hold of one.

Much later some people created SLIP (Serial Line IP) to enable a serial line to act as a carrier for the entire TCP/IP stack. A bit later PPP was introduced as an improvement. I think SLIP is still available for most platforms, and PPP exists on every platform that can do dial-up internet.

So if the question basically boils down to wanting to network two computers via PPP without going through somebody else's dial-up server (like Earthlink), what you need is to install a PPP server on one of the two machines. They come with most Linux distros. For Windows you will have to go look. I'd help, but my corporate blocker is being overexuberant again.

疧_╮線 2024-09-25 19:06:37

有人在这里用 C# 编写了 XModem 实现: http:// trackday.cc/b2evo/blog2.php/2007/08/02/net-xmodem 它可能对您的需求有所帮助。

Someone has written an XModem implementation in C# here: http://trackday.cc/b2evo/blog2.php/2007/08/02/net-xmodem It may help with what you're after.

三生路 2024-09-25 19:06:37

您的问题中不清楚的一件事是,您是否正在尝试使用电缆直接连接同一物理位置的两台计算机,或者是否尝试通过 PSTN 从另一台计算机拨入。

如果它们位于同一位置,请从等式中消除调制解调器。这显着降低了复杂性。

如果它们位于不同的位置(即通过诚实的拨号连接进行拨号),这里有一些代码可能对您有帮助。本文讨论的是蓝牙或 GPRS 调制解调器,但其核心是发送 AT 命令,可用于与任何 AT 命令集兼容的设备进行通信。它可能会让你朝着正确的方向前进。

更新

请参阅 http://msdn2.microsoft.com/en-us/system.io.ports.serialport(VS.80).aspx

由于调制解调器应该连接到 COM 端口 (COM1-COM12),即使它是一个内部调制解调器,您应该能够使用.NET框架的SerialPort类来打开端口,发送AT命令等。一旦您建立了开放的连接,您就可以使用XModem库来传输文件,或用于常规通信的直接串行。

您是否需要 IP 堆栈,或者您对直接串行协议感到满意吗?

One thing that's not clear from your question is whether you are attempting to directly connect two machines in the same physical location with a cable, or if you are attempting to dial in to one from the other over a PSTN.

If they are in the same place, eliminate the modem from the equation. This reduces complexity significantly.

If they are in separate locations (ie, dialing over an honest-to-God dial-up connection), there is some code here that might help you. The article talks about a Bluetooth or GPRS modem, but the core of it is about sending AT commands which can be used to talk to any AT-command set-compatible device. It might get you going in the right direction.

Update

See http://msdn2.microsoft.com/en-us/system.io.ports.serialport(VS.80).aspx

Since a modem should be attached to a COM port (COM1-COM12) even it is an internal modem, you should be able to use the .NET framework's SerialPort class to open the port, send AT commands, etc. Once you have an open connection, you could use the XModem library to transfer files, or straight serial for regular communications.

Do you need an IP stack, or are you happy with a straight serial protocol?

总攻大人 2024-09-25 19:06:37

您可以非常轻松地在需要使用调制解调器的 Windows 中设置拨号网络连接(位于设置 VPN 的选项下,但您可以将其设置为仅拨号)。

因此,我假设您可以将网络位置映射到它以供 C# 代码使用。

如前所述,至少有一个调制解调器必须打开并侦听连接。

* 编辑 *

我相信以下代码将触发已放置在网络连接中的拨号连接,

System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo(@"c:\Local Area Connection 2 - Shortcut");

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();

对于放置在 c:\ 驱动器并命名为“本地连接 2 - 快捷方式”的链接,

您可以然后 ping 目的地以查看其是否已连接。

但最终我认为最好的解决方案可能是使用 RAS。

看看 Codeplex:DotRAS

然后您可以使用以下代码:

RasDialer dialer = new RasDialer();

bool connected = false;
foreach (RasConnection connection in dialer.GetActiveConnections())
{
    if (connection.EntryName == "MyFriendsPC")
    {
        connected = true;
        break;
    }
}

if (!connected) {
    dialer.EntryName = "MyFriendsPC";
    dialer.Dial();

    // If you need to provide credentials, use the Dial(NetworkCredential) overload that's available.
}

此示例假设您已经有一个默认电话簿中名为 MyFriendsPC 的条目。如果您不这样做并且需要以编程方式创建此连接,则可以使用 RasPhoneBook 组件来实现。

RasPhoneBook pbk = new RasPhoneBook();
pbk.Open(); // This will open the phone book in the All Users profile.

RasEntry entry = new RasEntry("MyFriendsPC");

如果您希望使用连接的默认设置,您可以使用 RasEntry 类上的静态方法之一,或者在此处手动配置连接。

pbk.Entries.Add(entry);

将条目添加到集合后,它将立即添加到电话簿中。

You can quite easily setup dial-up network connections within Windows that require the use of a modem (its under the option for setting up a VPN, but you can set it for just a dial up).

So I would assume that you can then map a network location to it for use by your C# code.

As already stated at least one of the modems must be on and listening for a connection.

* edit *

I believe that the following code will trigger a dial-up connection that has been placed within Network Connections

System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo(@"c:\Local Area Connection 2 - Shortcut");

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();

For link placed at c:\ drive and named "Local Area Connection 2 - Shortcut"

You could then ping the destination to see if its connected.

Ultimately though I think that your best solution may be to use RAS.

Have a look here at Codeplex: DotRAS

You can then use the following code:

RasDialer dialer = new RasDialer();

bool connected = false;
foreach (RasConnection connection in dialer.GetActiveConnections())
{
    if (connection.EntryName == "MyFriendsPC")
    {
        connected = true;
        break;
    }
}

if (!connected) {
    dialer.EntryName = "MyFriendsPC";
    dialer.Dial();

    // If you need to provide credentials, use the Dial(NetworkCredential) overload that's available.
}

This example assumes you already have an entry named MyFriendsPC in the default phone book. If you do not and need to create this connection programmatically, you can use the RasPhoneBook component for that.

RasPhoneBook pbk = new RasPhoneBook();
pbk.Open(); // This will open the phone book in the All Users profile.

RasEntry entry = new RasEntry("MyFriendsPC");

If you'd rather use the default settings for the connection you can use one of the static methods on the RasEntry class, or manually configured the connection here.

pbk.Entries.Add(entry);

Once the entry has been added to the collection, it will immediately be added into the phone book.

唠甜嗑 2024-09-25 19:06:37

我最近想将拨号 POS 终端连接到模拟调制解调器。这并不困难,但是您需要引入一个 9 伏电池和一个并联的 200mA 电阻,以便调制解调器连接。 https://www.youtube.com/watch?v=luarFqislIc 介绍了该方法(跳至 11:30 查看电路)。如果没有电池和电阻提供环路电流(约 18mA),调制解调器将不会协商连接(进入 ATA 后您会听到调制解调器应答,但不会听到调制解调器协商的最后部分)。通过环路电流,调制解调器将连接。该视频甚至显示 ZModem 用于将文件从一台 PC 传输到另一台 PC。

视频中未提及的最后一项是该电路没有拨号音。要解决此问题,请在呼叫调制解调器上启用盲拨 (ATX1)。此外,由于这种方法没有振铃,因此将接收调制解调器设置为自动应答 (ATS0=1) 将不起作用。您必须在接收调制解调器上输入 ATA 才能应答。

I recently wanted to connect a dial-up POS terminal to an analog modem. This is not difficult, but you need to introduce a 9-volt battery and a 200mA resistor in parallel for the modems to connect. https://www.youtube.com/watch?v=luarFqislIc describes the approach (skip to 11:30 to see the circuit). Without the battery and resistor to provide the loop current (about 18mA), the modems will not negotiate a connection (you'll hear the modem after entering ATA to answer, but you won't hear the final part of the modem negotiation). With the loop current, the modems will connect. The video even shows ZModem being used to transfer a file from one PC to the other.

One final item not mentioned in the video is with this circuit, there is no dial tone. To get around this, enable blind dialing (ATX1) on the calling modem. Also, since there are no rings with this approach, setting the receiving modem to auto-answer (ATS0=1) won't work. You have to enter ATA on the receiving modem to answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文