Still not working
This commit is contained in:
parent
b38cf4807e
commit
7574cf9dd0
3 changed files with 25 additions and 25 deletions
|
@ -29,7 +29,7 @@ void OnTcpReceive(dword socket, long result, dword address, dword port, byte buf
|
|||
if (size == 0)
|
||||
{
|
||||
// Size of zero indicates that the socket was closed by the communication peer.
|
||||
writeLineEx(0, 2, "<%BASE_FILE_NAME%> OnTcpReceive: Socket closed by peer");
|
||||
writeLineEx(0, 2, "<%NODE_NAME%> OnTcpReceive: Socket closed by peer");
|
||||
g_%NODE_NAME%_Socket.Close();
|
||||
g_%NODE_NAME%_SocketState = CLOSED;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ void OnTcpReceive(dword socket, long result, dword address, dword port, byte buf
|
|||
{
|
||||
gIpLastErr = g_%NODE_NAME%_Socket.GetLastSocketError();
|
||||
g_%NODE_NAME%_Socket.GetLastSocketErrorAsString(gIpLastErrStr, elcount(gIpLastErrStr));
|
||||
writeLineEx(0, 2, "<%BASE_FILE_NAME%> OnTcpReceive error (%d): %s", gIpLastErr, gIpLastErrStr);
|
||||
writeLineEx(0, 2, "<%NODE_NAME%> OnTcpReceive error (%d): %s", gIpLastErr, gIpLastErrStr);
|
||||
g_%NODE_NAME%_Socket.Close();
|
||||
g_%NODE_NAME%_SocketState = CLOSED;
|
||||
}
|
||||
|
|
|
@ -34,19 +34,19 @@ word TcpOpenSocket()
|
|||
if (g_%NODE_NAME%_Socket.GetLastSocketError() != 0)
|
||||
{
|
||||
g_%NODE_NAME%_Socket.GetLastSocketErrorAsString(errorText, elcount(errorText));
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Error: could not open Tcp socket on %s:%d, %s (%d)!", Local_IP, localPort, errorText, g_%NODE_NAME%_Socket.GetLastSocketError());
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Error: could not open Tcp socket on %s:%d, %s (%d)!", Local_IP, localPort, errorText, g_%NODE_NAME%_Socket.GetLastSocketError());
|
||||
}
|
||||
}
|
||||
while (g_%NODE_NAME%_Socket.GetLastSocketError() != 0 && i++ < 9);
|
||||
|
||||
if (g_%NODE_NAME%_Socket.GetLastSocketError() != 0)
|
||||
{
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Error: could not open Tcp socket!");
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Error: could not open Tcp socket!");
|
||||
return g_%NODE_NAME%_Socket.GetLastSocketError();
|
||||
}
|
||||
else
|
||||
{
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Tcp socket opened on %s:%d.", Local_IP, localPort);
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Tcp socket opened on %s:%d.", Local_IP, localPort);
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
@ -60,7 +60,7 @@ word TcpConnectTo(char Remote_IP[], word remotePort)
|
|||
remoteIp = IpGetAddressAsNumber(Remote_IP);
|
||||
if (remoteIp == INVALID_IP)
|
||||
{
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Error: invalid server Ip address!");
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Error: invalid server Ip address!");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ word TcpConnectTo(dword remoteIp, word remotePort)
|
|||
|
||||
if (fehler != WSAEWOULDBLOCK) // OnTcpConnect will be called otherwise
|
||||
{
|
||||
write("<%BASE_FILE_NAME%> No Port-Connection: %d", fehler);
|
||||
write("<%NODE_NAME%> No Port-Connection: %d", fehler);
|
||||
g_%NODE_NAME%_SocketState = ERROR;
|
||||
return fehler;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ word TcpConnectTo(dword remoteIp, word remotePort)
|
|||
}
|
||||
else
|
||||
{
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Successfully connected to server");
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Successfully connected to server");
|
||||
g_%NODE_NAME%_SocketState = OK;
|
||||
return 0;
|
||||
}
|
||||
|
@ -110,13 +110,13 @@ void OnTcpConnect(dword socket, long result)
|
|||
if (result != 0)
|
||||
{
|
||||
g_%NODE_NAME%_Socket.GetLastSocketErrorAsString(gIpLastErrStr, elcount(gIpLastErrStr));
|
||||
writeLineEx(0, 2, "<%BASE_FILE_NAME%> OnTcpConnect error (%d): %s", g_%NODE_NAME%_Socket.GetLastSocketError(), gIpLastErrStr);
|
||||
writeLineEx(0, 2, "<%NODE_NAME%> OnTcpConnect error (%d): %s", g_%NODE_NAME%_Socket.GetLastSocketError(), gIpLastErrStr);
|
||||
g_%NODE_NAME%_SocketState = ERROR;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Successfully connected to server");
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Successfully connected to server");
|
||||
g_%NODE_NAME%_SocketState = OK;
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ void TcpRecv()
|
|||
if (gIpLastErr != WSA_IO_PENDING) // Calling OnTcpReceive otherwise
|
||||
{
|
||||
g_%NODE_NAME%_Socket.GetLastSocketErrorAsString(gIpLastErrStr, elcount(gIpLastErrStr));
|
||||
writeLineEx(0, 2, "<%BASE_FILE_NAME%> TcpReceive error (%d): %s", gIpLastErr, gIpLastErrStr);
|
||||
writeLineEx(0, 2, "<%NODE_NAME%> TcpReceive error (%d): %s", gIpLastErr, gIpLastErrStr);
|
||||
g_%NODE_NAME%_Socket.Close();
|
||||
g_%NODE_NAME%_SocketState = CLOSED;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ void TcpSnd(byte buffer[])
|
|||
}
|
||||
|
||||
bin_to_strhex(buffer, str);
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> TcpSnd: %s (Länge: %d)", str, elCount(buffer));
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> TcpSnd: %s (Länge: %d)", str, elCount(buffer));
|
||||
|
||||
if (g_%NODE_NAME%_Socket.Send(buffer, elCount(buffer)) != 0)
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ void TcpSnd(byte buffer[])
|
|||
if (gIpLastErr != WSA_IO_PENDING)
|
||||
{
|
||||
g_%NODE_NAME%_Socket.GetLastSocketErrorAsString(gIpLastErrStr, elcount(gIpLastErrStr));
|
||||
writeLineEx(0, 2, "<%BASE_FILE_NAME%> TcpSnd error (%d): %s", gIpLastErr, gIpLastErrStr);
|
||||
writeLineEx(0, 2, "<%NODE_NAME%> TcpSnd error (%d): %s", gIpLastErr, gIpLastErrStr);
|
||||
g_%NODE_NAME%_Socket.Close();
|
||||
g_%NODE_NAME%_SocketState = CLOSED;
|
||||
}
|
||||
|
|
|
@ -33,33 +33,33 @@ dword SetupIp(char Local_IP[])
|
|||
switch (adapterCount)
|
||||
{
|
||||
case 0:
|
||||
writeLineEx(0, 3, "<%BASE_FILE_NAME%> Error: There is no network interface available!");
|
||||
writeLineEx(0, 3, "<%NODE_NAME%> Error: There is no network interface available!");
|
||||
stop();
|
||||
return INVALID_IP;
|
||||
break;
|
||||
case 1:
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Info: There is 1 network interface available!");
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Info: There is 1 network interface available!");
|
||||
if (adapterIndex != 1)
|
||||
{
|
||||
writeLineEx(0, 3, "<%BASE_FILE_NAME%> Error: You have not selected the first adapter!");
|
||||
writeLineEx(0, 3, "<%NODE_NAME%> Error: You have not selected the first adapter!");
|
||||
stop();
|
||||
return INVALID_IP;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Info: There are %d network interfaces available!", adapterCount);
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Info: There are %d network interfaces available!", adapterCount);
|
||||
// // // // TEST \\ \\ \\ \\
|
||||
for (i = 1; i <= adapterCount; i++)
|
||||
{
|
||||
IpGetAdapterDescription(i, text, size);
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Info: Interface %d: %s", i, text);
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Info: Interface %d: %s", i, text);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (IpGetAdapterAddress(adapterIndex, addresses, 1) != 0)
|
||||
{
|
||||
writeLineEx(0, 3, "<%BASE_FILE_NAME%> Error: Could not retrieve IP address!");
|
||||
writeLineEx(0, 3, "<%NODE_NAME%> Error: Could not retrieve IP address!");
|
||||
stop();
|
||||
return INVALID_IP;
|
||||
}
|
||||
|
@ -68,24 +68,24 @@ dword SetupIp(char Local_IP[])
|
|||
|
||||
if (address == INVALID_IP)
|
||||
{
|
||||
writeLineEx(0, 3, "<%BASE_FILE_NAME%> Error: IP address to be used is invalid!");
|
||||
writeLineEx(0, 3, "<%NODE_NAME%> Error: IP address to be used is invalid!");
|
||||
stop();
|
||||
return INVALID_IP;
|
||||
}
|
||||
|
||||
IpGetAdapterDescription(adapterIndex, text, size);
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Interface: %s", text);
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Wrong interface? Change sysvar::TCPIP::AdapterIndex");
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Interface: %s", text);
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Wrong interface? Change sysvar::TCPIP::AdapterIndex");
|
||||
|
||||
IpGetAdapterAddressAsString(adapterIndex, text, size);
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Ip address: %s", text);
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Ip address: %s", text);
|
||||
strncpy(Local_IP, text, 16);
|
||||
|
||||
IpGetAdapterMaskAsString(adapterIndex, text, size);
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Subnet mask: %s", text);
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Subnet mask: %s", text);
|
||||
|
||||
IpGetAdapterGatewayAsString(adapterIndex, text, size);
|
||||
writeLineEx(0, 1, "<%BASE_FILE_NAME%> Gateway address: %s", text);
|
||||
writeLineEx(0, 1, "<%NODE_NAME%> Gateway address: %s", text);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue