I have tried to do a tcp send in autoit, http://www.autoitscript.com script but can't get it to function.
I have been told to do it in php, so i will try.
I will have to connect to a specific ip-adress, and a specific port, then send data by a socket connection, how do i do this?.
I have installed notepad++ and found some code to begin coding, but how do i execute the code? I want the php program to be executed as a standalone exe.
<?php
$handle = fsockopen('mail.uplinklounge.com', 25, $erno, $errstr, 30);
if (!$handle) {
//if connection fails exit and tell us what went wrong.
die("Connect failed: $errstr\n");
}
else {
$message = "MAIL FROM: iadnah@uplinklounge.com\r\n".
"RCPT TO: test@uplinklounge.com\r\n".
"data\r\n".
"Subject: this is a test\r\n".
"This is the contents of a mail\r\n".
".\r\n";
//read the first line the smtp server gives us (usually the version string)
$responses = fgets($handle, 1024);
//send our data to the smtp server
fwrite($handle, "$message");
/*
until there is no more output to read from the smtp server keep storing all the output
in the $responses variable. Once there's nothing else to read show us all the output
and exit
*/
while (!feof($handle)) {
$responses .= fgets($handle, 1024);
}
echo "$responses";
fclose($handle);
}
?>
tcp send
Moderator: General Moderators
Re: tcp send
could you rephrase you question. What exactly do you need? You seem to want to send an email.
Re: tcp send
Hello.
I want to connect to a specific ip-adress, and a specific port, then send an xml-data string by a socket connection, how do i do this?.

I want to connect to a specific ip-adress, and a specific port, then send an xml-data string by a socket connection, how do i do this?.
Re: tcp send
take a look at curl
Re: tcp send
Thanks.
I think i am coming somewhere now. I don't really know what curl is but found socket.
This will be my first code:
resource socket_create ( int $domain , int $type , int $protocol )
and i fill in it with my data:
resource socket_create ( int AF_INET6 , int SOCK_STREAM , int tcp )
If i understand it right i create a socket, and will now send data.
I think i will have to do socket connect:
bool socket_connect ( resource $socket , string $address [, int $port ] )
and my data
bool socket_connect ( resource $socket , string 66.66.66.66 [, int 6666 ] )
Now i send the string:
int socket_send ( resource $socket , string $buf , int $len , int MSG_EOR )
i will have my xml-data in $buf
Well, this is how i think i will program it, but i have never coded in php.
Can anyone help me to correct the code?
And how does i execute the code? Must i have a webserver installed?

I think i am coming somewhere now. I don't really know what curl is but found socket.
This will be my first code:
resource socket_create ( int $domain , int $type , int $protocol )
and i fill in it with my data:
resource socket_create ( int AF_INET6 , int SOCK_STREAM , int tcp )
If i understand it right i create a socket, and will now send data.
I think i will have to do socket connect:
bool socket_connect ( resource $socket , string $address [, int $port ] )
and my data
bool socket_connect ( resource $socket , string 66.66.66.66 [, int 6666 ] )
Now i send the string:
int socket_send ( resource $socket , string $buf , int $len , int MSG_EOR )
i will have my xml-data in $buf
Well, this is how i think i will program it, but i have never coded in php.
Can anyone help me to correct the code?
And how does i execute the code? Must i have a webserver installed?