Re: VB6 compatible Dll created with VC++6 problems using afxsock functions

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You did n't check errors in your code , so maybe that will tell something
Arkady

<matthieu.bocktaels@xxxxxxxxxxx> wrote in message
news:1151049148.299805.234260@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi

I've got a problem using send() function (defined in afxsock.h) in a
VB6 compatible DLL that I've made.

Let me explain the situation :

I'm coding a Server-Client application.
- The server runs on a XPEmbedded Windows, and is programmed with
VC++6. Sockets declarations and recv() & send() function are defined in
afxsock.h.
- The client runs on a Windows XP Fammily edition and is programmed in
VB6. I had some problems in making the both communicate beacause of the
limited size of paquets that can be send with winsock SendData in VB.
More over I had already written the Client program in VC++6 using
afxsock, that worked very well.

So I had written a VB6 compatible DLL with VC++ that I've included in
my VB code.

The Dll launches well as I can display some MsgBox, but the characters
send to the server aren't received altough the code is hardly the same
to my VC++ client program.

Are there some cautions to use send() in a Dll ?

Here are some pieces of my codes:

/////////////////////////////////////////
///// Client Dll /////////////////////
/////////////////////////////////////////

#define TRANSF_DTF 20


void __stdcall Transfert_DTF(LPSTR string)
{

WSADATA initialisation_win32;
SOCKET socketID;
SOCKADDR_IN Sock_addr;
unsigned char buffer[PAQUETETH];
unsigned char buffer_ack[4];
HANDLE hFile;
char temp[30];
int packetnbr, packetnbr_ack;
int size;

MessageBox(NULL,"Enter the DLL","Message",MB_OK);

hFile = CreateFile( string, // open file
GENERIC_READ, // open for reading
FILE_SHARE_READ, // share for reading
NULL, // no security
OPEN_EXISTING, // existing file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template

if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox(NULL, "Error", "Message", MB_OK);
}

size = GetFileSize(hFile,NULL);
sprintf(temp, "size : %d", size);
MessageBox(NULL,temp,"Message",MB_OK);

//
********************************************************
// Winsock Initialization

erreur=WSAStartup(MAKEWORD(2,2),&initialisation_win32);

socketID=socket(AF_INET,SOCK_STREAM,0);

Sock_addr.sin_family=AF_INET;
Sock_addr.sin_addr.s_addr=inet_addr("192.168.0.2");
Sock_addr.sin_port=htons(8686);

connect(socketID,(struct sockaddr*)&Sock_addr,sizeof(Sock_addr));

buffer_ack[3] = TRANSF_DTF;

compt = send(socketID, (char*)buffer_ack, 4, 0);
sprintf(temp, "Send : %d", compt);
MessageBox(NULL,temp,"Message",MB_OK);

compt = recv(socketID,(char*)buffer_ack,4,0);
sprintf(temp, "Recv : %d", compt);
MessageBox(NULL,temp,"Message",MB_OK);

/////////////////////////////////////////////////////////////



//////////////////////////
///// Server///////////
//////////////////////////

// Same initialisations, then : //

transf_sock = accept(socketID,(struct
sockaddr*)&Socket_addr.sin_addr,NULL);
popup(hWnd, "accepted", 40, NOIR); // display function

if(transf_sock == INVALID_SOCKET)
{
sprintf(temp,"error invalid transf_sock n° %d", WSAGetLastError());
popup(hWnd, temp, 10, NOIR);
}

recv(transf_sock,(char*)buffer_ack,4,NULL);
sprintf(temp, "interception : % d\n", (UCHAR)buffer_ack[3]);
popup(hWnd, temp, 70, NOIR);

/////////////////////////////////////////////////////////////


Both programs are blocked as the server don't receive the first 4
bytes...


Someone can help me ?

Thanks.

Matthieu.


.



Relevant Pages

  • A Simple Unix Forking Server and Client
    ... UNIX‑domain sockets. ... The server program should be able to handle ... I have wriiten a server progam and a client program which reads one ... void error ...
    (comp.unix.programmer)
  • VB6 compatible Dll created with VC++6 problems using afxsock functions
    ... VB6 compatible DLL that I've made. ... Sockets declarations and recv& sendfunction are defined in ... More over I had already written the Client program in VC++6 using ... send to the server aren't received altough the code is hardly the same ...
    (microsoft.public.vc.language)
  • VB6 compatible Dll created with VC++6 problems using afxsock functions
    ... VB6 compatible DLL that I've made. ... Sockets declarations and recv& sendfunction are defined in ... More over I had already written the Client program in VC++6 using ... send to the server aren't received altough the code is hardly the same ...
    (microsoft.public.win32.programmer.networks)
  • Re: Banana Republic (was Re: OpenVMS Book Wins award)
    ... client ... No bollocks HTTP, SOAP, XML, Java, Garbage ... receive messages from any number of server processes who in turn could be ... Unlike TCP/IP and/or UDP Sockets with Java that have been around since ...
    (comp.os.vms)
  • Example: Socket code (Was Re: ClientServer App)
    ... protocol, such as HTTP, as your application middleware backbone?". ... control of the server with Flash Data Management Services?" ... just enter an asterix "*" for the Queue Name and then click ... thought was to use sockets with xml-rpc but then thought there has to ...
    (comp.lang.java.programmer)