我要监听某一端口(例如:3052)上其他IP发过来的消息,应该用哪个控件,具体如何实现,最好有代码
另外如何把接受到的二进制消息转换为字符串,应该用那些字符串函数?

解决方案 »

  1.   

    把二进制消息转换为十六进制字符串,以便显示。type
      function Frame2Hex(const Frame: string): string; 
      function Frame2Hex(const Frame: array of Byte): string;...implementation...function Frame2Hex(const Frame: string): string; 
    var
      i: Integer;
    begin
      Result := '';
      for i:=1 to Length(Frame) do
        Result := Result + IntToHex(Byte(Frame[i]), 2) + ' ';
    end;function Frame2Hex(const Frame: array of Byte): string;
    var
      i: Integer;
    begin
      Result := '';
      for i:=0 to High(Frame) do
        Result := Result + IntToHex(Frame[i], 2) + ' ';
    end;
      

  2.   

    把二进制消息转换为十六进制字符串,以便显示。type
      function Frame2Hex(const Frame: string): string; overload;
      function Frame2Hex(const Frame: array of Byte): string; overload;...implementation...function Frame2Hex(const Frame: string): string; 
    var
      i: Integer;
    begin
      Result := '';
      for i:=1 to Length(Frame) do
        Result := Result + IntToHex(Byte(Frame[i]), 2) + ' ';
    end;function Frame2Hex(const Frame: array of Byte): string;
    var
      i: Integer;
    begin
      Result := '';
      for i:=0 to High(Frame) do
        Result := Result + IntToHex(Frame[i], 2) + ' ';
    end;
      

  3.   

    这里有一个监听 5023 端口的例子:
    http://community.csdn.net/Expert/topic/3846/3846408.xml?temp=.6689569使用控件:TServerSocket
      

  4.   

    我的delphi7.0在internet中没有TServerSocket、TClientSocket控件,为什么??
      

  5.   

    component--->install packages-->add---->添加bin目录里dclsockets70.bpl 就能在internet上面看到这两个控件了