收听远程计算机发送的来电显示(C#) [英] Listening to Caller ID sent by remote computer (C#)

查看:130
本文介绍了收听远程计算机发送的来电显示(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我有一个VoIP调制解调器,我把它连接到我家的电脑。我用作服务器的程序是 YAC(又一个来电显示)。在我的笔记本电脑中,由于我使用Ethereal来收听来电显示信息,这里有一个示例文字:

Hi. I have a VoIP modem and I connect it to my family's computer. The program that I use which serves as a server is YAC (Yet Another Caller ID). In my laptop, since I used Ethereal to listen to the caller ID info, here's an example text:

.. k..h .....`..E..I9d @ ... .......... |?)。 .... Ey.YP ....... @ CALLYAC 测试电话〜(425)555-1212

..k..h.....`..E..I9d@...?..........|).....Ey.YP.......@CALLYAC Test Call ~(425) 555-1212

正如我所看到的那样在十六进制编辑器和分组信息中,MAC目的地与"... K..h"相关联,源与"....."相关联,类型(IP)与0x0800相关联。使用"..",接下来是Internet协议(E..I9d @ ..?.........),包含源端口,目标端口,seq,ack和len的传输控制协议(不知道seq和ack是什么但我打赌"len"代表"length"并且指的是如果我是正确的字节数),以及TCP Segment Data,它们有类似这样的& "@CALLYAC测试呼叫〜(425)555-1212"。

As I can tell by looking at the hex editor and packet information, the MAC Destination are associated with "..K..h", the source are associated with ".....`", a type (IP) with 0x0800 which is associated with "..", next is Internet Protocol (E..I9d@..?.........), Transmission Control Protocol that contains source port, destination port, seq, ack, and len (don't know what seq and ack is but I bet "len" stands for "length" and refers to number of bytes if I'm correct), and TCP Segment Data, which have something like this "@CALLYAC Test Call ~(425) 555-1212".

我真正感兴趣的一件事是@CALL,但我更倾向于具体,因为有两个端口:一个来源端口和目标端口。当然,它可能总是不是33个字节,因为来电显示中的某些文字可能是错误的。

One thing that really interest me is @CALL, but I'd rather be specific since there's two ports: a source port and destination port. Of course, it may always not be 33 bytes because some text in Caller ID can be wrong.

当我查看代码时:

< font face ="Courier New,Courier,Monospace"> TcpListener server = null ;
尝试
{
//在端口13000上设置TcpListener。
Int32 port = 13000;
IPAddress localAddr = IPAddress.Parse(" 127.0.0.1");

// TcpListener server = new TcpListener(port );
server = new TcpListener(localAddr,port);

/ /开始侦听客户端请求。
server.Start();

//用于读取数据的缓冲区
字节[] bytes = new 字节[256];
字符串数据= null ;
< br> //输入监听循环。
while true
{
Console.Write("Waiting a connection ...");

//执行阻止调用接受请求。
//您也可以在这里使用server.AcceptSocket()。
TcpClient client = server.AcceptTcpClient ();
Console.WriteLine(" Connected!");

data = null ;

//获取用于读写的流对象

NetworkStream stream = client.GetStream();

int i;

//循环接收客户端发送的所有数据。
while ((i = stream.Read(bytes,0,bytes.Length))!= 0)
{
//将数据字节转换为a ASCII字符串。
data = System.Text.Encoding.ASCII.GetString(bytes,0,i);
Console.WriteLine(" Received:{0}",data); < br>
//处理客户端发送的数据。
data = data.ToUpper();

byte [] msg = System.Text.Encoding.ASCII.GetBytes(data);

//发送回复。
stream.Write(msg,0,msg.Length);
Console.WriteLine(" Sent:{0}",data);
}

//关闭和结束连接
client.Close();
}


catch (SocketException e)
{
Console.WriteLine(" SocketException:{0}",e);
}
最后
{
//停止侦听新客户端。
server.Stop ();
}


Console.WriteLine(" \\\
Hit enter to continue ...");
Console.Read();

    TcpListener server=null;  
    try
    {
      // Set the TcpListener on port 13000.
      Int32 port = 13000;
      IPAddress localAddr = IPAddress.Parse("127.0.0.1");
     
      // TcpListener server = new TcpListener(port);
      server = new TcpListener(localAddr, port);

      // Start listening for client requests.
      server.Start();
        
      // Buffer for reading data
      Byte[] bytes = new Byte[256];
      String data = null;

      // Enter the listening loop.
      while(true)
      {
        Console.Write("Waiting for a connection... ");
       
        // Perform a blocking call to accept requests.
        // You could also user server.AcceptSocket() here.
        TcpClient client = server.AcceptTcpClient();           
        Console.WriteLine("Connected!");

        data = null;

        // Get a stream object for reading and writing
        NetworkStream stream = client.GetStream();

        int i;

        // Loop to receive all the data sent by the client.
        while((i = stream.Read(bytes, 0, bytes.Length))!=0)
        {  
          // Translate data bytes to a ASCII string.
          data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
          Console.WriteLine("Received: {0}", data);
      
          // Process the data sent by the client.
          data = data.ToUpper();

          byte[] msg = System.Text.Encoding.ASCII.GetBytes(data);

          // Send back a response.
          stream.Write(msg, 0, msg.Length);
          Console.WriteLine("Sent: {0}", data);           
        }
        
        // Shutdown and end connection
        client.Close();
      }
    }
    catch(SocketException e)
    {
      Console.WriteLine("SocketException: {0}", e);
    }
    finally
    {
       // Stop listening for new clients.
       server.Stop();
    }

     
    Console.WriteLine("\nHit enter to continue...");
    Console.Read();

我注意到它只侦听特定的IP地址,但我想要一个程序来监听任何IP地址(好的,私有IP地址,但它不一定是C类私有IP地址) ,特别是192.168.xx)。因此,当我使用来电显示信息检测到数据包时,我可以提取来电者姓名和来电号码。此外,由于TTY(电传打字机;用于聋/听力诅咒)无法听到(它只闪一盏灯),我可以播放音频文件让我知道我接到了一个电话,没有购买一个在TTY电话响铃时发出声音的电话报警器,我将自己编码。

I noticed that it only listens to specific IP address but I wanted a program to listen to any IP address (well, private IP address but it doeesn't have to be a Class C Private IP Address, notably 192.168.x.x). So when I detect the packet with Caller ID information, I can be able to extract the caller name and caller phone number. Plus, since the TTY (teletypewriter; used for the deaf/hearing imparied) can't be audible (it only flashes a light), I can be able to play an audio file to let me know that I got a phone call, without purchasing a phone alerter that makes sound when TTY phone rings, which I'll do coding by my own.

偏离主题:对于那些想要质疑我使用我的TTY而不是VoIP的人(Vonage,我目前正在与Comcast一起使用),我首先使用有线调制解调器,第二个连接到电缆调制解调器的Motorola VT2142电话适配器,以及连接到我的电话适配器的第三个路由器。我的信号非常清晰,没有任何乱码。 TTY,以及我的电话适配器和路由器在楼下,而我的笔记本电脑位于楼上,所以由于我一直使用笔记本电脑,我无法知道是谁打电话给我,但即使我已经下载了YAC(还记得我提供的链接吗?)并运行YAC Listener,它没有能够播放音频文件让我知道,所以如果我能帮助检测我想要的数据包将会很棒获取来电显示信息,我不必错过任何一个电话。我的路由器是D-Link DI-524。

Off-topic: For those who want to question me about using my TTY over VoIP (Vonage, which I'm currently using with Comcast), I have the cable modem first, Motorola VT2142 phone adapter second that connects to cable modem, and router third which connects to my phone adapter. I get very clear signal without any garbled text. The TTY, along with my phone adapter and router are downstairs, whereas my laptop are located upstairs, so since I use my laptop all the time, I can't be able to know who calls me, but even though I have downloaded YAC (remember the link that I've provided?) and run a YAC Listener, it doesn't have the ability to play audio files to let me know, so it will be great if I could help detect the packet that I wanted to get when getting caller ID information and that I don't have to miss a phone call. The router that I have is D-Link DI-524.

推荐答案

好的。我有一个关于从我的笔记本电脑分配到192.168.0.2的TCP端口的后续问题。

OK. I have a follow-up question about listening to TCP port from 192.168.0.2 that my laptop's assigned to.

IPAddress ip = IPAddress .Parse( " 192.168.0.2" );

IPAddress ip = IPAddress.Parse ( "192.168.0.2" );

TcpListener 服务器;

TcpListener server;

//

TcpClient client;

TcpClient client;

NetworkStream stm;

NetworkStream stm;

public Form1()

public Form1 ( )

{

InitializeComponent();

InitializeComponent ( );

尝试

try

{

server = new TcpListener (ip,10629);

server = new TcpListener ( ip , 10629 );

server.Start();

server.Start ( );

labelListener.Text =

labelListener.Text =

"听取连接..." ;

"Listening for a connection...";

bool pending = server.Pending();

bool pending = server.Pending ( );

(!server.Pending())

while ( !server.Pending ( ) )

{

pending = server.Pending();

pending = server.Pending ( );

if (server.Pending())

if(server.Pending())

client = server.AcceptTcpClient();

client = server.AcceptTcpClient ( );

}

labelListener.Text = " Connected!\ n" ;

labelListener.Text = "Connected!\n";

}

catch SocketException ex)

catch ( SocketException ex )

{

MessageBox .Show(ex.ToString());

MessageBox.Show ( ex.ToString ( ) );

}

}

当我调试代码时," client = server.AcceptTcpClient();"因为"服务器"而没有被执行不接受待处理的连接。有办法吗?

As I've debugged the code, "client = server.AcceptTcpClient ( );" doesn't get executed because the "server" doesn't accept pending connections. Is there a way around it?


这篇关于收听远程计算机发送的来电显示(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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