English 中文(简体)
简单的袖珍,有:
原标题:simple socket with php and delphi?

我有一个使用TTCPServer部件在Delphi书写的简单服务器,它有一个真正基本的OnAccept事件程序,如下文......。

“10000”

procedure TMainWindow.TcpServerAccept(Sender: TObject;
  ClientSocket: TCustomIpClient);
var
  S: String;
begin
  S := ClientSocket.Receiveln();
  ShowMessage(S);
  ShowMessage(IntToStr(Length(S)));

  Memo1.Lines.Add(S);
end;

简便的“加拿大”一页。

<?php
$address =  127.0.0.1 ;
$port = 10000;
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($sock, $address, $port);

socket_set_option($sock, SOL_SOCKET, SO_KEEPALIVE, 1);
$msg =  Hello...! ;
echo socket_write($sock, $msg, strlen($msg));

socket_close($sock);
?> 

Now the problem is when I m trying to write into the connected socket with php page no error occurred but the received text in the Delphi application (listener) show me the wrong result some thing like this "效汬⹯⸮!"

what should I do ???

最佳回答

“Restrong>Remy Lebeau” 说,Delphi 2009+读写了统法协会编码表格,但《价格指数》关于根据地貌变化编码编码编码编码的十年。 为了解决这个问题,我们需要在德尔菲斯听众申请中使用像“Unicode2Ascii”这样的功能。

问题回答

这一职能应满足你们的需要(我希望)

function UTF8ToUTF16(AUTF8String: RawByteString): String;
begin
  SetCodePage(AUTF8String, 0, False);
  Result := AUTF8String;
end;

现在你们应该能够这样做:

procedure TMainWindow.TcpServerAccept(Sender: TObject;
  ClientSocket: TCustomIpClient);
var
  S: String;
begin
  S := UTF8ToUTF16(ClientSocket.Receiveln());
  ShowMessage(S);
  ShowMessage(IntToStr(Length(S)));

  Memo1.Lines.Add(S);
end;




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签