このコードは、私のソケット リスナー プログラムのスピネットです。問題は、メッセージ全体を受け取っていないことです。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
{
助けてくれてありがとう。