Raised This Month: $32 Target: $400
 8% 

Module: Threaded Sockets


Post New Thread Reply   
 
Thread Tools Display Modes
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 09-16-2015 , 15:45   Re: Module: Threaded Sockets
Reply With Quote #31

Quote:
Originally Posted by Shooting King View Post
I am not sure i understood you draft, Can you give me an Example ? And tell me what you want to do ? Actually i didn't understand that suggestion too
I send 2 packets thought the module. Then, I get 2 responses. How can I know what response corresponds to what packet?

That's what he is trying to explain.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 09-17-2015 , 03:55   Re: Module: Threaded Sockets
Reply With Quote #32

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
I send 2 packets thought the module. Then, I get 2 responses. How can I know what response corresponds to what packet?

That's what he is trying to explain.
Based upon iThreadHandle ? Cmon people give me an example where are you facing the problem
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 09-17-2015 at 04:01.
Shooting King is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 09-22-2015 , 14:14   Re: Module: Threaded Sockets
Reply With Quote #33

Quote:
Originally Posted by Shooting King View Post
Based upon iThreadHandle ? Cmon people give me an example where are you facing the problem
He meant using the same g_iThreadHandle.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 09-23-2015 , 08:13   Re: Module: Threaded Sockets
Reply With Quote #34

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
He meant using the same g_iThreadHandle.
It depends on what he wants to do. Let him post his problem Neel
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Nixon133
Junior Member
Join Date: Jan 2014
Old 11-20-2015 , 12:17   Re: Module: Threaded Sockets
Reply With Quote #35

Hi. Can I add a new cornfield to get ip address of the server? His replacement get_user_ip (0, ...).
Nixon133 is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 11-22-2015 , 05:01   Re: Module: Threaded Sockets
Reply With Quote #36

Whats a cornfield ? native ? Whats the problem with get_user_ip() ? What exactly are you trying to do ?
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Nixon133
Junior Member
Join Date: Jan 2014
Old 11-22-2015 , 05:37   Re: Module: Threaded Sockets
Reply With Quote #37

Quote:
Originally Posted by Shooting King View Post
Whats a cornfield ? native ? Whats the problem with get_user_ip() ? What exactly are you trying to do ?
Problem in that through cvar. of net_address IP can change (visually). At this get_user_ip(0) will give out this address, but not real IP servers.
Nixon133 is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 11-22-2015 , 12:22   Re: Module: Threaded Sockets
Reply With Quote #38

I don't understand why do you change net_address and why you want to get the real address now ? Anyways getting Global ip from within the same system is hard to implement and even though if implemented cannot guarantee you the correct result. One thing you can do is get a server (hosted on a different network) to echo your IP back.

If you have a web-server make a simple script to echo REMOTE_ADDR HTTP var. Using php,
PHP Code:
<?php echo "Your Current IP is " $_SERVER["REMOTE_ADDR"];
Using sockets (from amxx plugin) request and read http page and using RegEx extract IP from it. You can do this by just editing the Example1 given in the first post.

A simple code (test yourself),
PHP Code:
#include <amxmodx>
#include <sockets>
#include <regex> 

#define BUFFER_LEN    512

new g_iThreadHandle
new 
pCvar_HostNamepCvar_Page

new 
szBuffer[BUFFER_LEN];

public 
plugin_init()
{
    
register_plugin"Global IP""1.0""Shooting King" );
    
register_concmd"/test" "TestCmd" );

    
pCvar_HostName register_cvar"sk_ts_hostname""localhost" ); // Change this to your hostname
    
pCvar_Page register_cvar"sk_ts_reqpage""/" );
}

public 
TestCmd() 

    
g_iThreadHandle socket_create_t(); 
     
    new 
szHostName[64]; 
    
get_pcvar_stringpCvar_HostNameszHostName64 ); 
     
    
socket_open_t(g_iThreadHandleszHostName80SOCKET_TCP"CBOpenSocket");


public 
CBOpenSocketiThreadStateiReturn 

    if( 
iReturn 
    { 
        
log_amx"ERROR: Could not open Socket. Error[%d] : %d"iReturnsocket_get_last_error_t(g_iThreadHandle) ); 
    } 
    else 
    {         
        new 
szPacket[128];  
        new 
szHostName[64], szPage[64]; 
        
get_pcvar_stringpCvar_HostNameszHostName64 ); 
        
get_pcvar_stringpCvar_PageszPage64 ); 
         
        
formatexszPacket127"GET %s HTTP/1.1^r^nHost: %s^r^n^r^n"szPageszHostName ); 
        
socket_send_tg_iThreadHandleszPacketsizeof(szPacket), "CBSendSocket");
    } 


public 
CBSendSocketiThreadStateiReturn 

    if( 
iReturn 
    { 
        
log_amx"ERROR: Error Sending Data. Error[%d] : %d"iReturnsocket_get_last_error_t(g_iThreadHandle) ); 
    } 
    else 
    {
        
szBuffer[0] = '^0';
        
socket_recv_tg_iThreadHandle"CBRecvSocket"64 );
    } 


public 
CBRecvSocketiThreadStateiReturnszRecvData[], iRecvDataLen 

    if( 
iReturn <= 
    {
        
socket_close_t(g_iThreadHandle"CBCloseSocket"); 
        new 
reterror[2], szIP[16];

        new 
Regex:regex_handle regex_match(szBuffer"Your Current IP is ([0-9.]*)"reterrorcharsmax(error));    
        if( 
regex_handle REGEX_NO_MATCH )
        {
            
regex_substr(regex_handle1szIPcharsmax(szIP));        
            
log_amx"IP : %s" szIP );
            
regex_free(regex_handle);
        }
        else
        {
            
log_amx"No IP found in RecvData" );
        }
    }
    else 
    { 
        
strcatszBufferszRecvDataBUFFER_LEN );
    } 


public 
CBCloseSocketiThreadStateiReturn 

    
socket_destroy_t(g_iThreadHandle); 

You don't specifically need a webserver, any game server or any server capable of listening and sending your ip back can do the trick.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Nixon133
Junior Member
Join Date: Jan 2014
Old 11-22-2015 , 12:46   Re: Module: Threaded Sockets
Reply With Quote #39

Whether and it is possible to realize it, native?
To receive IP as you did it in Module: Fake Server Queries. Inet_ntoa function.

Whether also there will be a continuation of the module? Improvement, completion?
Nixon133 is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 11-22-2015 , 13:31   Re: Module: Threaded Sockets
Reply With Quote #40

Quote:
Originally Posted by Nixon133 View Post
Whether and it is possible to realize it, native?
To receive IP as you did it in Module: Fake Server Queries. Inet_ntoa function.
No

Quote:
Originally Posted by Nixon133 View Post
Whether also there will be a continuation of the module? Improvement, completion?
Yes
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:08.


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