LordoToasty
System.ArgumentOutOfRangeException: Pls Help :.)
"currentcase |= BoolToByte(pre64_bits[(i * 6) + j]);"
It's this line that causes the problem and I know what OutOfRangeException in general means, but I don't get where my math sucked hard enough to throw that exception.
6 replies
PCP request to router (port forwarding) problem.
// Receive the response packet from the PCP server
byte[] responsePacket = new byte[128];
int bytesReceived = socket.ReceiveFrom(responsePacket, responsePacket.Length, SocketFlags.None, ref serverAddress, ref serverPort);
// Parse the response packet
int lifetime = responsePacket[4]; // Lifetime in seconds
int protocol = responsePacket[8]; // Protocol
int internalPort = responsePacket[12]; // Internal port
byte[] assignedExternalPort = new byte[2];
Array.Copy(responsePacket, 14, assignedExternalPort, 0, 2); // Assigned external port (2 bytes)
byte[] assignedExternalIPAddress = new byte[16];
Array.Copy(responsePacket, 16, assignedExternalIPAddress, 0, 16); // Assigned external IP address (16 bytes)
5 replies
PCP request to router (port forwarding) problem.
// Create a socket for UDP communication with the PCP server
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
// Set the PCP server address and port
IPAddress serverAddress = IPAddress.Parse("192.168.1.100");
int serverPort = 65536; // PCP port
// Create a request packet
byte[] requestPacket = new byte[128];
// Set the request opcode
requestPacket[0] = 0x06; // MAP opcode
// Set the requested lifetime in seconds
requestPacket[4] = 0; // 0 seconds (delete)
// Set the protocol
requestPacket[8] = 17; // TCP protocol
// Set the internal port
requestPacket[12] = 0; // All ports
// Set the suggested external port
requestPacket[14] = 0;
socket.SendTo(requestPacket, requestPacket.Length, SocketFlags.None, serverAddress, serverPort);
5 replies
Timer, devideFound and Background Thread!
Update: So if you care...it turned out that Device Lost is automatically called whenever the Port-Mapping expires, this way I've just put in the same line of code to create a portmat. The result is quite obvious considering this loop works (it does indeed work).
29 replies