LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-31-2009, 01:15 AM   #1
naveenisback
Member
 
Registered: Jun 2009
Posts: 80
Blog Entries: 1

Rep: Reputation: 16
how to make compatible communication between linux and win32


Hi,


I wrote a server program in redflag(almost like redhat). I am using 'char' buffer to send the message to client(running in windows). I succeed in communicating between server and client. when i try to print the message in client(code written in vc++, and the receive buffer type is TCHAR), it is printing in the form of boxes.


After i realised that the size of wchar_t in unix is 32 bit and in win32 it is 16 bit. si i used iconv() call to convert to 16 bit format and trying to send, but this time, I am able to send 4 characters only.

pls suggest some ideas to make compatible communication between windows ang linux.

Thankz in Advance.

converting function from utf8 to utf-16
Code:
char* convert(char* inbuf, int length)
{
        iconv_t cd;
        char *instr;
        char *outbuf;
        char *outptr;
        unsigned int insize=length;
        unsigned int outputbufsize=4096;
        unsigned int avail=outputbufsize;
        unsigned int nconv;

        instr=inbuf;
        outbuf=(char *)malloc(outputbufsize);
        outptr=outbuf;
        memset(outbuf,'\0',outputbufsize);

        cd=iconv_open("utf-16", "utf-8");
        if(cd==(iconv_t)-1)
        {
                printf("fail.\n");
        }
        nconv=iconv(cd,&instr,&insize,&outptr,&avail);

return outbuf;
}
 
Old 07-31-2009, 08:55 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Just a guess that your sending function uses something like sizeof(outbuf) when sending to the client. As outbuf is a pointer, its size is 4 (in 32 bit environments).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
hot can make a text browser compatible mior of a sit that isnt normally compatible markyg852 Programming 2 04-14-2009 09:22 AM
MacOsX, Darwin, *Nix BSD: Can we make linux and Mac compatible for programs ? frenchn00b Linux - General 1 02-17-2008 01:00 PM
C++ and OpenGL- how to make programs/games compatible with both windows and linux uveraser Programming 9 06-16-2004 02:38 PM
Sniffing Serial/IrDA-Communication of Win32-App to create Open Interface PSIplus Programming 0 06-02-2004 07:58 PM
Lets make Linux more compatible el_pajaro! Linux - Hardware 2 11-09-2003 03:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration