mattias1975
Programmer
I have problem with sending stuff with sockets.
There seems to something wrong when i call the sendto function.
Does anyone know what it is?
Thank you.
Mattias Westerberg
#include <winsock2.h>
#include <wininet.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
void main(){
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
cout << "could not find a usable WinSock DLL\n";
}
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) {
WSACleanup( );
cout << "could not find a usable WinSock DLL\n";
}
int sock = socket (PF_INET, SOCK_RAW, IPPROTO_TCP);
if (sock == SOCKET_ERROR)
cout << "Socket error!\n";
struct sockaddr_in name;
name.sin_family = AF_INET;
name.sin_addr.s_addr = inet_addr("213.67.159.89");
name.sin_port = htons(25);
char test[] = "bla bla bla";
cout << sizeof(test);
int s = sendto(sock, test, sizeof(test), 0 ,(struct sockaddr *) &name, sizeof(name));
if(s < 0)
cout << "Send error!\n";
}
There seems to something wrong when i call the sendto function.
Does anyone know what it is?
Thank you.
Mattias Westerberg
#include <winsock2.h>
#include <wininet.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
void main(){
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
cout << "could not find a usable WinSock DLL\n";
}
if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) {
WSACleanup( );
cout << "could not find a usable WinSock DLL\n";
}
int sock = socket (PF_INET, SOCK_RAW, IPPROTO_TCP);
if (sock == SOCKET_ERROR)
cout << "Socket error!\n";
struct sockaddr_in name;
name.sin_family = AF_INET;
name.sin_addr.s_addr = inet_addr("213.67.159.89");
name.sin_port = htons(25);
char test[] = "bla bla bla";
cout << sizeof(test);
int s = sendto(sock, test, sizeof(test), 0 ,(struct sockaddr *) &name, sizeof(name));
if(s < 0)
cout << "Send error!\n";
}