her er min kode(det er når jeg er inde i passport problemet kommer):
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
#pragma comment(lib,"ws2_32.lib")
#include <time.h>
#include <errno.h>
#include <string>
#include <iostream>
SOCKET startwinsock(char *addres, int port);
void split(char *text, char *sign, int number, char *back);
void Passport(char *code, char *key);
int main()
{
char temp[20], tempchar[20], longchar[255];
int tempint;
long rc;
SOCKET s = startwinsock("207.46.104.20", 1863);
char buf[256];
char sending[256];
strcpy(sending, "VER 1 MSNP8 CVR0\\r\\n\\0");
send(s, sending, strlen(sending), 0);
while(rc!=SOCKET_ERROR){
strcpy(buf, "");
strcpy(sending, "");
rc=recv(s,buf,256,0);
if (strnicmp(buf,"VER",3) == 0) {
strcpy(sending, "CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS andreas_the_programmer@hotmail.com\\r\\n\\0");
}
else if (strnicmp(buf,"CVR",3) == 0){
strcpy(sending, "USR 3 TWN I andreas_the_programmer@hotmail.com\\r\\n");
}
else if (strnicmp(buf,"XFR",3) == 0) {
split(buf, " ", 3, temp);
tempint = 1;
split(temp, ":", 0, tempchar);
std::cout << "temp: " << temp << "\\ntempchar: " << tempchar << "\\n";
closesocket(s);
s = startwinsock(tempchar, 1863);
strcpy(sending, "VER 1 MSNP8 CVR0\\r\\n\\0");
}
else if (strnicmp(buf,"USR",3) == 0) {
tempint = 0;
for (int x=12; x<= strlen(buf);x++){
longchar[tempint] = buf[x];
tempint++;
}
longchar[tempint] = '\\0';
std::cout << "Ved USR og longchar: " << longchar << "\\nbuf:" << buf << "\\n";
char key[255];
Passport(longchar,key);
}
if (strlen(sending) > 0) {
send(s, sending, strlen(sending), 0);
printf("here\\n");
}
if(rc==0)
{
printf("connection closed...\\n");
break;
}
if(rc==SOCKET_ERROR)
{
printf("error receiving... %d\\n",WSAGetLastError());
break;
}
buf[rc]='\\0';
printf("\\nServer answered: %s\\n",buf);
}
closesocket(s);
WSACleanup();
return 0;
}
SOCKET startwinsock(char *addres, int port){
SOCKADDR_IN addr;
long rc;
SOCKET s;
WSADATA wsa;
rc=WSAStartup(MAKEWORD(2,0),&wsa);
if(rc!=0) printf("Error: startWinsock : %d\\n",rc);
s=socket(AF_INET,SOCK_STREAM,0);
if(s==INVALID_SOCKET) printf("%d\\n",WSAGetLastError());
memset(&addr,0,sizeof(SOCKADDR_IN));
addr.sin_family=AF_INET;
addr.sin_port=htons(port);
addr.sin_addr.s_addr=inet_addr(addres); // connect to "messenger.hotmail.com"
rc=connect(s,(SOCKADDR*)&addr,sizeof(SOCKADDR));
if(rc==SOCKET_ERROR) printf("connect failed: %d\\n",WSAGetLastError());
return s;
}
void split(char *text, char *sign, int number, char *back){
int x,z,a,b[20],c;
char y[20];
b[0] = -1;
c=1;
for (x=1; x<=strlen(text); x++){
a=0;
for (z=x; z<= x+strlen(sign)-1 && z <= strlen(text); z++){
if (text[z] == sign[z-x]) {a++;}
}
if (a==strlen(sign)) { b[c]= x; c++;}
}
a=0;
for (x=b[number]+1; x<=b[number+1]-1; x++) {
y[a] = text[x];
a++;
}
y[a] = 0;
for (x=0; x<=a; x++) {
std::cout << "y[" << x << "]: " << y[x] << "\\n";
}
strcpy(back, y);
}
void Passport(char *code, char *key){
char buf[256];
char sending[256];
long rc;
bool a = true;
SOCKET p = startwinsock("65.54.179.228",443);
send(p, "GET /rdr/pprdr.asp HTTP/1.0\\r\\n\\r\\n\\0", strlen("GET /rdr/pprdr.asp HTTP/1.0\\r\\n\\r\\n\\0"), 0);
std::cout << "Ved Passport\\n";
while(rc!=SOCKET_ERROR && a == true){
strcpy(buf, "");
strcpy(sending, "");
rc=recv(p,buf,256,0);
if (strlen(buf) > 0) {std::cout << "MODTAGET i Passport :)\\n";}
if (strlen(sending) > 0) {
send(p, sending, strlen(sending), 0);
printf("here23\\n");
}
if(rc==0)
{
printf("connection closed2...\\n");
break;
}
if(rc==SOCKET_ERROR)
{
printf("error receiving2... %d\\n",WSAGetLastError());
break;
}
buf[rc]='\\0';
printf("\\nServer answered2: %s\\n",buf);
}
}
ps. jeg ved godt det er en blanding af C# og C++, det er fordi jeg fik en til at hjælpe mig lidt, og har ikke lavet det om siden.