Raised This Month: $ Target: $400
 0% 

[SOLVED]Socket_Send problem/question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
InfiniTy.
Junior Member
Join Date: Dec 2012
Old 12-28-2012 , 14:34   [SOLVED]Socket_Send problem/question
Reply With Quote #1

So i have this code :

Code:
formatex( szData, charsmax( szData ), "GET /cs/page.php?n=%s HTTP/1.1^r^nHost:%s^r^nConnection: close^r^n^r^n", pName, gRedirectHost );
	
	socket_send( RedirectSocket, szData, charsmax( szData ) );
And the problem is it doesn't do nothing or something that i want.. the question is how would i corect this code in order to work ?
What i'm trying to do is this :
When the plugins starts access the link
mysite.mydomain/cs/page.php?n=ACvarName
And the rest is php which i know how to do.. also i don't know if socket_send is the thing for me or not..

Last edited by InfiniTy.; 12-29-2012 at 05:03.
InfiniTy. is offline
LAMMPARD8_PRO
Member
Join Date: Dec 2012
Old 12-28-2012 , 15:47   Re: Socket_Send problem/question
Reply With Quote #2

AMXX Studio --> Generators --> Connection generator.
Create your connection via amxx generator.
__________________
[IMG]http://img24.**************/img24/3333/92810204.png[/IMG]
LAMMPARD8_PRO is offline
InfiniTy.
Junior Member
Join Date: Dec 2012
Old 12-28-2012 , 17:00   Re: Socket_Send problem/question
Reply With Quote #3

Quote:
Originally Posted by LAMMPARD8_PRO View Post
AMXX Studio --> Generators --> Connection generator.
Create your connection via amxx generator.
I don't really .. understand the code that it makes..
InfiniTy. is offline
LAMMPARD8_PRO
Member
Join Date: Dec 2012
Old 12-28-2012 , 17:26   Re: Socket_Send problem/question
Reply With Quote #4

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <sockets> // sockets include
#include <amxmisc>
new sckSTREAM //var socket name

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
/* Init CVars for the socket "STREAM"  */
    
if (cvar_exists("amx_STREAM_socket")) {
        
sckSTREAM get_cvar_num("amx_STREAM_socket"//value number
        
read_STREAM()
    }
    else
        
register_cvar("amx_STREAM_socket""0"FCVAR_PROTECTED&FCVAR_UNLOGGED)
    
/* up u change to readable value End */
}

/* Socket STREAM */

public connect_STREAM() { // called if you connect to ur socket connection
    
new error 0
    sckSTREAM 
socket_open("servecounterstrike.com"80SOCKET_TCPerror// the info (site, port usage, type)
    
if (sckSTREAM 0) {
        
/* Connect successful */
        
read_STREAM()
    }
    else {
        switch (
error) {
            case 
1: { /* Error creating socket */ //in cases when fails..
            
case 2: { /* Could not resolve hostname */ }
            case 
3: { /* Could not connect to given host:port */ }
        }
    }
}

public 
read_STREAM() { //called while socket is in use
    
if (socket_change(sckSTREAM100)) {
        new 
buf[512], lines[30][100], count 0
        socket_recv
(sckSTREAMbuf511)
        
count ExplodeString(lines2999buf13)
        for(new 
i=0;i<count;i++) {
            
/* Process items here  (functions etc..)*/
        
}
    }
    
    if (
sckSTREAM != 0)
        
set_task(0.5"read_STREAM")
    else {
        
set_cvar_num("amx_STREAM_socket"0)
        
disconnect_STREAM()
    }
}

public 
write_STREAM(text[512]) {
    
socket_send(sckSTREAMtext511)
}

public 
disconnect_STREAM() {
    
/* Disconnected */
}

stock ExplodeStringp_szOutput[][], p_nMaxp_nSizep_szInput[], p_szDelimiter ) { // Function by xeroblood
    
new nIdx 0strlen(p_szInput)
    new 
nLen = (copycp_szOutput[nIdx], p_nSizep_szInputp_szDelimiter ))
    while( (
nLen l) && (++nIdx p_nMax) )
        
nLen += (copycp_szOutput[nIdx], p_nSizep_szInput[nLen], p_szDelimiter ))
    return 
nIdx

__________________
[IMG]http://img24.**************/img24/3333/92810204.png[/IMG]
LAMMPARD8_PRO is offline
LAMMPARD8_PRO
Member
Join Date: Dec 2012
Old 12-28-2012 , 17:28   Re: Socket_Send problem/question
Reply With Quote #5

you can pass in <sockets> #pragma also
__________________
[IMG]http://img24.**************/img24/3333/92810204.png[/IMG]
LAMMPARD8_PRO is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-28-2012 , 22:29   Re: Socket_Send problem/question
Reply With Quote #6

Quote:
Originally Posted by LAMMPARD8_PRO View Post
you can pass in <sockets> #pragma also
Huh? What are you talking about?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
LAMMPARD8_PRO
Member
Join Date: Dec 2012
Old 12-28-2012 , 22:57   Re: Socket_Send problem/question
Reply With Quote #7

Pragma Directives. but nvm.
__________________
[IMG]http://img24.**************/img24/3333/92810204.png[/IMG]
LAMMPARD8_PRO is offline
InfiniTy.
Junior Member
Join Date: Dec 2012
Old 12-29-2012 , 05:03   Re: Socket_Send problem/question
Reply With Quote #8

Quote:
Originally Posted by LAMMPARD8_PRO View Post
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <sockets> // sockets include
#include <amxmisc>
new sckSTREAM //var socket name

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
/* Init CVars for the socket "STREAM"  */
    
if (cvar_exists("amx_STREAM_socket")) {
        
sckSTREAM get_cvar_num("amx_STREAM_socket"//value number
        
read_STREAM()
    }
    else
        
register_cvar("amx_STREAM_socket""0"FCVAR_PROTECTED&FCVAR_UNLOGGED)
    
/* up u change to readable value End */
}

/* Socket STREAM */

public connect_STREAM() { // called if you connect to ur socket connection
    
new error 0
    sckSTREAM 
socket_open("servecounterstrike.com"80SOCKET_TCPerror// the info (site, port usage, type)
    
if (sckSTREAM 0) {
        
/* Connect successful */
        
read_STREAM()
    }
    else {
        switch (
error) {
            case 
1: { /* Error creating socket */ //in cases when fails..
            
case 2: { /* Could not resolve hostname */ }
            case 
3: { /* Could not connect to given host:port */ }
        }
    }
}

public 
read_STREAM() { //called while socket is in use
    
if (socket_change(sckSTREAM100)) {
        new 
buf[512], lines[30][100], count 0
        socket_recv
(sckSTREAMbuf511)
        
count ExplodeString(lines2999buf13)
        for(new 
i=0;i<count;i++) {
            
/* Process items here  (functions etc..)*/
        
}
    }
    
    if (
sckSTREAM != 0)
        
set_task(0.5"read_STREAM")
    else {
        
set_cvar_num("amx_STREAM_socket"0)
        
disconnect_STREAM()
    }
}

public 
write_STREAM(text[512]) {
    
socket_send(sckSTREAMtext511)
}

public 
disconnect_STREAM() {
    
/* Disconnected */
}

stock ExplodeStringp_szOutput[][], p_nMaxp_nSizep_szInput[], p_szDelimiter ) { // Function by xeroblood
    
new nIdx 0strlen(p_szInput)
    new 
nLen = (copycp_szOutput[nIdx], p_nSizep_szInputp_szDelimiter ))
    while( (
nLen l) && (++nIdx p_nMax) )
        
nLen += (copycp_szOutput[nIdx], p_nSizep_szInput[nLen], p_szDelimiter ))
    return 
nIdx

Hm.. :-? thanks
InfiniTy. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-29-2012 , 13:42   Re: Socket_Send problem/question
Reply With Quote #9

Quote:
Originally Posted by LAMMPARD8_PRO View Post
Pragma Directives. but nvm.
What does that have to do with SQL?
__________________
fysiks is offline
LAMMPARD8_PRO
Member
Join Date: Dec 2012
Old 12-29-2012 , 14:07   Re: [SOLVED]Socket_Send problem/question
Reply With Quote #10

i've heard that pragma can be used for optimization and making 1 include file to be only single.
It helps a lot in programs, maded by hex editor, but amxxstudio support that too.
__________________
[IMG]http://img24.**************/img24/3333/92810204.png[/IMG]
LAMMPARD8_PRO is offline
Reply


Thread Tools
Display Modes

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 13:23.


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