internal static byte[] getInfo(IPEndPoint ipe, Packet packet) { //Create the socket Socket srvSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Save the max packet size int packetSize = 12288; //Send/Receive timeouts srvSocket.SendTimeout = 3000; srvSocket.ReceiveTimeout = 3000; try { //Send the request to the server srvSocket.SendTo(packet.outputAsBytes(), ipe); } catch (SocketException se) { throw new SSQLServerException("Could not send packet to server {" + se.Message + "}"); } //Create a new receive buffer byte[] rcvPacketInfo = new byte[packetSize]; EndPoint Remote = (EndPoint)ipe; int recvdBytes = -1; try { //Receive the data from the server recvdBytes = srvSocket.ReceiveFrom(rcvPacketInfo, ref Remote); } catch (SocketException se) { throw new SSQLServerException("Could not receive packet from server {" + se.Message + "}"); } if (recvdBytes < sizeof(uint)) { return(null); } uint headerInt = BitConverter.ToUInt32(rcvPacketInfo, 0); if (headerInt != 0xFFFFFFFF) //we only support simple non-split packets for this query { return(null); } int realDataSize = recvdBytes - sizeof(uint); //Send the packet data back byte[] retnData = new byte[realDataSize]; Array.Copy(rcvPacketInfo, sizeof(uint), retnData, 0, realDataSize); return(retnData); }
internal static byte[] getInfo(IPEndPoint ipe, Packet packet) { //Create the socket Socket srvSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Save the max packet size int packetSize = 12288; //Send/Receive timeouts srvSocket.SendTimeout = 3000; srvSocket.ReceiveTimeout = 3000; try { //Send the request to the server srvSocket.SendTo(packet.outputAsBytes(), ipe); } catch (SocketException se) { throw new SSQLServerException("Could not send packet to server {" + se.Message + "}"); } //Create a new receive buffer byte[] rcvPacketInfo = new byte[packetSize]; EndPoint Remote = (EndPoint)ipe; int recvdBytes = -1; try { //Receive the data from the server recvdBytes = srvSocket.ReceiveFrom(rcvPacketInfo, ref Remote); } catch (SocketException se) { throw new SSQLServerException("Could not receive packet from server {" + se.Message + "}"); } if (recvdBytes < sizeof(uint)) return null; uint headerInt = BitConverter.ToUInt32(rcvPacketInfo, 0); if (headerInt != 0xFFFFFFFF) //we only support simple non-split packets for this query return null; int realDataSize = recvdBytes - sizeof(uint); //Send the packet data back byte[] retnData = new byte[realDataSize]; Array.Copy(rcvPacketInfo, sizeof(uint), retnData, 0, realDataSize); return retnData; }
internal static byte[] getInfo(IPEndPoint ipe, Packet packet) { //Create the socket Socket srvSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Save the max packet size int packetSize = 12288; //Send/Receive timeouts srvSocket.SendTimeout = 3000; srvSocket.ReceiveTimeout = 3000; try { //Send the request to the server srvSocket.SendTo(packet.outputAsBytes(), ipe); } catch (SocketException se) { throw new SSQLServerException("Could not send packet to server {" + se.Message + "}"); } //Create a new receive buffer byte[] rcvPacketInfo = new byte[packetSize]; EndPoint Remote = (EndPoint)ipe; try { //Receive the data from the server srvSocket.ReceiveFrom(rcvPacketInfo, ref Remote); } catch (SocketException se) { throw new SSQLServerException("Could not receive packet from server {" + se.Message + "}"); } //Send the information back return rcvPacketInfo; }
internal static byte[] getInfo(IPEndPoint ipe, Packet packet) { //Create the socket Socket srvSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Save the max packet size int packetSize = 12288; //Send/Receive timeouts srvSocket.SendTimeout = 3000; srvSocket.ReceiveTimeout = 3000; try { //Send the request to the server srvSocket.SendTo(packet.outputAsBytes(), ipe); } catch (SocketException se) { throw new SSQLServerException("Could not send packet to server {" + se.Message + "}"); } //Create a new receive buffer byte[] rcvPacketInfo = new byte[packetSize]; EndPoint Remote = (EndPoint)ipe; try { //Receive the data from the server srvSocket.ReceiveFrom(rcvPacketInfo, ref Remote); } catch (SocketException se) { throw new SSQLServerException("Could not receive packet from server {" + se.Message + "}"); } //Send the information back return(rcvPacketInfo); }