0
Answer

pleassssssssssssssssssssse I need a help

fofa

fofa

17y
1.9k
1

please I want conveart this code to vb.net

this code is written in c++

++++++++++++++++++++++++++++++

#include <windows.h>

#include <winsock.h>

#include <iostream>

using namespace std;

#pragma comment(lib, "wsock32.lib")

#define CS_ERROR 1

#define CS_OK 0

void WriteToExcel(char*);

void WriteToExcel2(char*);

int main()

{

WORD version;

WSADATA wsaData;

int rVal=0, x=0, i, n=1, choice=0;

char* env;

env = new char[5000];

char* data;

data = new char[5000];

char buf[500000]="",input[20]="",PCName[30]="";

bool InvalidChoice=false;

FILE *out;

FILE *in;

for(i=0;i<(int)strlen(buf);i++)

buf[i]='\0';

for(i=0;i<5000;i++)

env[i]='\0';

for(i=0;i<5000;i++)

data[i]='\0';

for(i=0;i<30;i++)

PCName[i]='\0';

version = MAKEWORD(1,1);

WSAStartup(version,(LPWSADATA)&wsaData);

LPHOSTENT hostEntry;

//store information about the server

//c31bl3-5.ccisgls.ksu.edu.sa

//

in = fopen("ComputerName.txt","r");

if (in)

{

fscanf(in,"%s",PCName);

fclose(in);

}

else

{

// fprintf(out,"%s\n",data);

// fclose(out);

cout<<"Please enter your computer name:"<<endl;

cin>>PCName;

cout<<endl<<endl;

in = fopen("ComputerName.txt","w");

fprintf(in,"%s\n",PCName);

fclose(in);

}

//

hostEntry = gethostbyname(PCName);

if(!hostEntry)

{

//sError("Failed gethostbyname()");

cout<<"Socket error : Failed gethostbyname."<<endl;

WSACleanup();

return CS_ERROR;

}

//create the socket

SOCKET theSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);

if(theSocket == SOCKET_ERROR)

{

//sError("Failed socket()");

cout<<"Socket error : Failed socket."<<endl;

WSACleanup();

return CS_ERROR;

}

//Fill in the sockaddr_in struct

SOCKADDR_IN serverInfo;

serverInfo.sin_family = PF_INET;

serverInfo.sin_addr = *((LPIN_ADDR)*hostEntry->h_addr_list);

serverInfo.sin_port = htons(8888);

rVal=connect(theSocket,(LPSOCKADDR)&serverInfo, sizeof(serverInfo));

if(rVal==SOCKET_ERROR)

{

//sError("Failed connect()");

cout<<"Socket error: Failed connect."<<endl;

WSACleanup();

return CS_ERROR;

}