Shahin
Shahin

Reputation: 12861

Connection between 2 computers via dial up modem without internet in c#

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.

Upvotes: 7

Views: 9403

Answers (6)

Goal Man
Goal Man

Reputation: 191

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.

Upvotes: 0

ChrisBD
ChrisBD

Reputation: 9209

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.

Upvotes: 1

3Dave
3Dave

Reputation: 29081

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?

Upvotes: 1

T.E.D.
T.E.D.

Reputation: 44814

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.

Upvotes: 4

Richard
Richard

Reputation: 109200

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.

Upvotes: 5

John Warlow
John Warlow

Reputation: 2992

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.

Upvotes: 1

Related Questions