이 코드는 소켓 수신기 프로그램에서 가져온 것입니다. 문제는 내가 전체 메시지를 듣지 못하고 있다는 것이다. 나는 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() 명령을 영원히 차단하지 않고이 작업을 수행 할 수있는 코드 예제를 제공 할 수 있습니까? –
제이, 저는 당신의 아이디어를 제 코드의 기초로 사용했고 오늘 아침에 클라이언트와 함께 테스트 할 것입니다. 필요한 경우 답변 및 업데이트로 표시하겠습니다. 도움에 다시 한번 감사드립니다. –