Código PHP:
public Byte[] GetLongMsg(Socket server)
{
Byte[] header = new Byte[8];
Byte[] bytesReceived = new Byte[150000];
int recibido = 0;
int indice = 0;
try
{
recibido = server.Receive(header, header.Length, SocketFlags.None); //header
indice += recibido;
recibido = server.Receive(bytesReceived, bytesReceived.Length, SocketFlags.None); //mensaje
indice += recibido;
while (server.Available > 0) //si quedan datos por recibir
{
Byte[] bytesAvailable = new Byte[server.Available];
recibido = server.Receive(bytesAvailable, bytesAvailable.Length, SocketFlags.None);
indice += recibido;
bytesAvailable.CopyTo(bytesReceived, indice);
}
if (header[0] == 255 && header[1] == 255)
{
MessageBox.Show(Encoding.ASCII.GetString(bytesReceived), "Error");
return null;
}
server.Close();
}
catch (SocketException e)
{
MessageBox.Show(e.Message, "Error");
return null;
}
return bytesReceived;
}
Gracias