please I want conveart this code to vb.net
this code is written in c++
++++++++++++++++++++++++++++++
#include
#include
#include
using
namespace std;#pragma
comment(lib, "wsock32.lib")#define
CS_ERROR 1#define
CS_OK 0void
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:"<cin>>PCName;
cout< in = fopen(
fprintf(in,
"%s\n",PCName);fclose(in);
}
//hostEntry = gethostbyname(PCName);
if(!hostEntry){
//sError("Failed gethostbyname()");cout<<
"Socket error : Failed gethostbyname."<WSACleanup();
}
//create the socketSOCKET theSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if(theSocket == SOCKET_ERROR){
//sError("Failed socket()");cout<<
"Socket error : Failed socket."<WSACleanup();
}
//Fill in the sockaddr_in structSOCKADDR_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."<WSACleanup();
}
Replies
Know the answer? Post it — somebody with the same question will find it here.