Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6049023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:31:46+00:00 2026-05-23T07:31:46+00:00

I am attempting to create an application that will call a remote modem and

  • 0

I am attempting to create an application that will call a remote modem and do some data transfer (custom data in the form of byte arrays).

I am using JulMar’s ITapi3 wrapper and c# 4.0 running on Windows 7 64Bit OS (Compiling as x86).

I have the application making the phone call and disconnecting as I expect but I am having trouble actually sending data across the line. Currently I have the following code in the CallStateChanged event when the call state is connected

  var handleArray = callForData.GetID("comm/datamodem");

        var byteContents = BitConverter.ToInt64(handleArray, 0);
        ////temporary Handle array
        IntPtr myPointer =new IntPtr(byteContents);


        ////var pinnedArray = GCHandle.Alloc(handleArray, GCHandleType.Pinned);
        ////var pointer = pinnedArray.AddrOfPinnedObject();
        var commHandle = new SafeFileHandle(myPointer, true);
        try
        {
           //now init filestream
            _dataTransferOutFileStream = new FileStream(commHandle, FileAccess.ReadWrite, 2048, true);

            //start by writing the login message to the modem
            var buffer = CreatePasswordMessage();

       IAsyncResult result= _dataTransferOutFileStream.BeginWrite(buffer, 0, buffer.Length,null,null);

        while (!result.IsCompleted)
            {
            //wait for completion of sending login message.
            Thread.Sleep(10);
            }

            //now we are done with sending login message 
       _dataTransferOutFileStream.EndWrite(result);

            //wait 5 seconds 
            Thread.Sleep(5000);
            //do the same type of thing for the read or whether it was sucessful.
        var readBuffer = new byte[2048];
        IAsyncResult readResult = _dataTransferOutFileStream.BeginRead(readBuffer, 0, 2048,null,null);
        while (!readResult.IsCompleted)
            {
            Thread.Sleep(10);
            }

            //read is complete.

       int readCount = _dataTransferOutFileStream.EndRead(readResult);

            Debug.WriteLine("Read Complete Count of Bytes Read: {0} Content of First Byte: {1} ",new object[]{readCount,readBuffer[0]});
        }

        catch (Exception ex)
        {
            Debug.WriteLine(ex.ToString());
            return false;
        }
        finally
        {

            commHandle.Close();

        }




        return true;

This doesn’t seem to be actually sending the data or recieving any valid data from the remote site. Is there something I am missing? Is there a way to check whether the SafeFileHandle being used is actually a reference to the modem’s port?

I tried using the builtin SerialPort class for .NET after I am connected but I get an error that the port in question is in use by another process (I am assuming TAPI has a lock on it.)

I am open to all suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:31:46+00:00Added an answer on May 23, 2026 at 7:31 am

    Ok I figured out what the issue was. Apparently I was formatting the data I was sending to the remote modem incorrectly and rather than the remote site telling me that it was simply ignoring my message altogether.

    So the code above will work for sending and receiving data asynchronously over a modem line in C#.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create a small application to collect data received from an
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I'm attempting to create a simple web application for some personal development, but I've
I want to create a timesheet application where I need an application that will
I am trying to create a script that will open an application in a
I'm attempting to create my first real C# application - a small pet project
I'm currently attempting to create a tabbed interface in a web application, and based
I am attempting to add Entity Framework, code first, to an MVC application that's
I am attempting to create a very graphically intensive android application. Almost all of
In the example console app below, you will notice that the program is attempting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.