mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Web: Show right message when invalid IP provided
This commit is contained in:
parent
cef1e5b484
commit
6e57334f9a
@ -272,7 +272,6 @@
|
|||||||
<ClCompile Include="Graphics.c" />
|
<ClCompile Include="Graphics.c" />
|
||||||
<ClCompile Include="Gui.c" />
|
<ClCompile Include="Gui.c" />
|
||||||
<ClCompile Include="HeldBlockRenderer.c" />
|
<ClCompile Include="HeldBlockRenderer.c" />
|
||||||
<ClCompile Include="interop_web.c" />
|
|
||||||
<ClCompile Include="Inventory.c" />
|
<ClCompile Include="Inventory.c" />
|
||||||
<ClCompile Include="Launcher.c" />
|
<ClCompile Include="Launcher.c" />
|
||||||
<ClCompile Include="LScreens.c" />
|
<ClCompile Include="LScreens.c" />
|
||||||
|
@ -545,8 +545,5 @@
|
|||||||
<ClCompile Include="Platform_Posix.c">
|
<ClCompile Include="Platform_Posix.c">
|
||||||
<Filter>Source Files\Platform</Filter>
|
<Filter>Source Files\Platform</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="interop_web.c">
|
|
||||||
<Filter>Source Files\Platform</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -282,10 +282,14 @@ cc_result Socket_GetError(cc_socket s, cc_result* result) {
|
|||||||
|
|
||||||
cc_result Socket_Connect(cc_socket s, const cc_string* ip, int port) {
|
cc_result Socket_Connect(cc_socket s, const cc_string* ip, int port) {
|
||||||
char addr[NATIVE_STR_LEN];
|
char addr[NATIVE_STR_LEN];
|
||||||
|
int res;
|
||||||
Platform_EncodeUtf8(addr, ip);
|
Platform_EncodeUtf8(addr, ip);
|
||||||
|
|
||||||
/* returned result is negative for error */
|
/* returned result is negative for error */
|
||||||
return -interop_SocketConnect(s, addr, port);
|
res = -interop_SocketConnect(s, addr, port);
|
||||||
|
|
||||||
|
/* error returned when invalid address provided */
|
||||||
|
if (res == EHOSTUNREACH) return ERR_INVALID_ARGUMENT;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Socket_Read(cc_socket s, cc_uint8* data, cc_uint32 count, cc_uint32* modified) {
|
cc_result Socket_Read(cc_socket s, cc_uint8* data, cc_uint32 count, cc_uint32* modified) {
|
||||||
@ -293,8 +297,8 @@ cc_result Socket_Read(cc_socket s, cc_uint8* data, cc_uint32 count, cc_uint32* m
|
|||||||
int res; *modified = 0;
|
int res; *modified = 0;
|
||||||
|
|
||||||
while (count) {
|
while (count) {
|
||||||
res = interop_SocketRecv(s, data, count);
|
|
||||||
/* returned result is negative for error */
|
/* returned result is negative for error */
|
||||||
|
res = interop_SocketRecv(s, data, count);
|
||||||
|
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
*modified += res;
|
*modified += res;
|
||||||
@ -309,8 +313,8 @@ cc_result Socket_Read(cc_socket s, cc_uint8* data, cc_uint32 count, cc_uint32* m
|
|||||||
}
|
}
|
||||||
|
|
||||||
cc_result Socket_Write(cc_socket s, const cc_uint8* data, cc_uint32 count, cc_uint32* modified) {
|
cc_result Socket_Write(cc_socket s, const cc_uint8* data, cc_uint32 count, cc_uint32* modified) {
|
||||||
int res = interop_SocketSend(s, data, count);
|
|
||||||
/* returned result is negative for error */
|
/* returned result is negative for error */
|
||||||
|
int res = interop_SocketSend(s, data, count);
|
||||||
|
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
*modified = res; return 0;
|
*modified = res; return 0;
|
||||||
@ -325,8 +329,8 @@ cc_result Socket_Close(cc_socket s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
|
cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
|
||||||
int res = interop_SocketPoll(s), flags;
|
|
||||||
/* returned result is negative for error */
|
/* returned result is negative for error */
|
||||||
|
int res = interop_SocketPoll(s), flags;
|
||||||
|
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
flags = mode == SOCKET_POLL_READ ? 0x01 : 0x02;
|
flags = mode == SOCKET_POLL_READ ? 0x01 : 0x02;
|
||||||
@ -391,19 +395,18 @@ int Platform_EncodeUtf8(void* data, const cc_string* src) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Platform_DescribeError(cc_result res, cc_string* dst) {
|
cc_bool Platform_DescribeError(cc_result res, cc_string* dst) {
|
||||||
char chars[NATIVE_STR_LEN];
|
char* str;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* For unrecognised error codes, strerror_r might return messages */
|
/* For unrecognised error codes, strerror might return messages */
|
||||||
/* such as 'No error information', which is not very useful */
|
/* such as 'No error information', which is not very useful */
|
||||||
/* (could check errno here but quicker just to skip entirely) */
|
|
||||||
if (res >= 1000) return false;
|
if (res >= 1000) return false;
|
||||||
|
|
||||||
len = strerror_r(res, chars, NATIVE_STR_LEN);
|
str = strerror(res);
|
||||||
if (len == -1) return false;
|
if (!str) return false;
|
||||||
|
|
||||||
len = String_CalcLen(chars, NATIVE_STR_LEN);
|
len = String_CalcLen(str, NATIVE_STR_LEN);
|
||||||
String_AppendUtf8(dst, chars, len);
|
String_AppendUtf8(dst, str, len);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user