此代码是我的套接字侦听器程序中的一个尖晶石。问题是我没有收到全部信息。我收到 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
{
感谢您的帮助。