AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sockets | server hangs (https://forums.alliedmods.net/showthread.php?t=253774)

Administrator 12-28-2014 09:20

Sockets | server hangs
 
Please tell me why the server hangs when sending a message?

PHP Code:

#include <amxmodx>
#include <sockets>

#define MESSAGE "Сообщение"
#define IP "127.0.0.1" // ip сайта
#define DOMAIN "domain.ru" // домен
#define PHP "/vk_message.php" // путь до php скрипта

public plugin_init()
{
    
register_plugin("VK send message""0.1""Stolen")
    
register_clcmd("say /vksend""send");
}

public 
send()
{
    new 
sockerrorpack[128]
    
format(packsizeof(pack), "GET %s?message='%s' HTTP/1.1^nHost:%s^r^n^r^n"PHPMESSAGEDOMAIN)
    
sock socket_open(IP80SOCKET_TCPerror)
    
socket_send(sockpacksizeof(pack))
    
socket_close(sock)



YamiKaitou 12-28-2014 11:20

Re: Sockets | server hangs
 
2 things I can see that might be the cause is using the single-quotes around the second %s and MESSAGE not being HTML safe. Another cause may be on the receiving end, check to see if the connection even opens

Also, use charsmax instead of sizeof for strings

Administrator 12-29-2014 07:12

Re: Sockets | server hangs
 
PHP Code:

#include <amxmodx>
#include <sockets_hz>

#define MESSAGE "blabla"
#define IP "46.254.21.136" // ip сайта
#define DOMAIN "74pp.ru" // домен
#define PHP "/vk_message.php" // путь до php скрипта

public plugin_init()
{
    
register_plugin("VK send message""0.1""Stolen")
    
register_concmd("vksend""send");
}

public 
send()
{
    new 
sockerrorpack[128]
    
format(packsizeof(pack), "GET %s?message=%s HTTP/1.1^nHost:%s^r^n^r^n"PHPMESSAGEDOMAIN)
    
sock socket_open(IP80SOCKET_TCPerror)
    
socket_send(sockpacksizeof(pack))
    
socket_close(sock)


so do not hang normally do?

baneado 12-29-2014 07:17

Re: Sockets | server hangs
 
you only have listened one thing he said ._.

Administrator 12-29-2014 07:34

Re: Sockets | server hangs
 
sorry, did not understand

YamiKaitou 12-29-2014 07:37

Re: Sockets | server hangs
 
Code:

sizeof(pack)
:arrow:
Code:

charsmax(pack)

Also, have you tested your new code? Have you looked at the receiving end to see if it is even getting the request?

Administrator 12-29-2014 07:41

Re: Sockets | server hangs
 
message comes up to me

YamiKaitou 12-29-2014 07:57

Re: Sockets | server hangs
 
Okay, so then is your issue resolved?

Administrator 12-29-2014 08:12

Re: Sockets | server hangs
 
Yes, thank you very much

Administrator 12-29-2014 13:06

Re: Sockets | server hangs
 
PHP Code:

#include <amxmodx>
#include <sockets_hz>

#define MESSAGE "eeee"
#define IP "46.254.21.136" // ip сайта
#define DOMAIN "74pp.ru" // домен
#define PHP "/vk_message.php" // путь до php скрипта
#define PHPP "/vkk_message.php" // путь до php скрипта

public plugin_init()
{
    
register_plugin("VK send message""0.1""Stolen")
    
register_concmd("vksend""sendd");
}

public 
send()
{
    
sendd()
    new 
sockerrorpack[128]
    
format(packcharsmax(pack), "GET %s?message=%s HTTP/1.1^nHost:%s^r^n^r^n"PHPMESSAGEDOMAIN)
    
sock socket_open(IP80SOCKET_TCPerror)
    
socket_send(sockpackcharsmax(pack))
    
socket_close(sock)
}

public 
sendd()
{
    new 
sockerrorpack[128]
    
format(packcharsmax(pack), "GET %s?message=%s HTTP/1.1^nHost:%s^r^n^r^n"PHPPMESSAGEDOMAIN)
    
sock socket_open(IP80SOCKET_TCPerror)
    
socket_send(sockpackcharsmax(pack))
    
socket_close(sock)


if two messages, the server hangs for 3 seconds


All times are GMT -4. The time now is 15:18.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.