このコードは、私のソケットリスナープログラムのスピネッツです。問題は、私は全体のメッセージを取得していないということです。私は1382バイトを受け取っています。しかし、コードでわかるように、配列サイズを15000に定義しました。切り詰められた着信ソケットメッセージ
namespace Listener
{
class Server
{
static void Main(string[] args)
{
IPAddress localAddr = IPAddress.Parse(args[0]);
System.Console.WriteLine("The local IP is {0}",
localAddr);
Int32 port = int.Parse(args[1]);
System.Console.WriteLine("The port is {0}", port);
TcpListener myListener = new TcpListener(localAddr,
port);
byte[] bytes = new byte[15000];
string sem = "";
do
{
Console.Write("Waiting");
myListener.Start();
Socket mySocket = myListener.AcceptSocket();
// receiving the hl7 message
mySocket.Receive(bytes);
string receiveMessage =
Encoding.ASCII.GetString(bytes);
// write out the hl7 message to a receiving
folder
DateTime currentDate = DateTime.Now;
long eTicks = currentDate.Ticks;
System.IO.File.WriteAllText(@"y:\results\" +
eTicks + ".hl7", receiveMessage);
// build the acknowledgemnent message to send
back to the client
try
{
ありがとうございました。
ジェイは完璧に動作するように思えます。 Receive()コマンドを永久にブロックせずにこれを行うコードの例を提供できますか? –
ジェイ、私はあなたの考えを自分のコードの基礎として使い、今朝クライアントとテストします。私はこれを答えて、必要に応じて更新します。助けてくれてありがとう。 –