Re: Help porting UNIX Socket Based App
From: thatsalok (thatsalok_at_NOSPAM.gmail.com.REMOVE)
Date: 02/23/05
- Next message: Ivan Starr: "What's the best way to determine effective file creation/write rights??"
- Previous message: Scott McPhillips [MVP]: "Re: Threads and Socket Design problem"
- In reply to: Jim Jones: "Help porting UNIX Socket Based App"
- Next in thread: Joseph M. Newcomer: "Re: Help porting UNIX Socket Based App"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Feb 2005 22:00:07 +0530
//here is basic Socket code which is compitable with Windows
//now you have to modify that accroding to your need
int gaim_remote_session_connect(int session)
{
SOCKET fd;
stored_uid, euid;
struct sockaddr_in saddr;
if ((fd = socket(AF_INET,SOCK_STREAM, 0)) != -1)
{
saddr.in_family=AF_INET;
saddr.sin_port=ntol(4000);//change to actual port
saddr.sin_addr.s_addr=inet_addr("");//give the remote ip here
if (connect(fd, (struct sockaddr *) &saddr, sizeof (saddr))
!= -1) return fd; } close(fd); return -1; }i think i have ported
almost 70% of your unix code rest your have to port your self
With Regard'sAlok Guptavisit me at http://alok.bizhat.com
"Jim Jones" <jim@pleaseremovethisalongwithdash-qtextender.com> wrote in
message news:OQJ1OvaGFHA.3608@TK2MSFTNGP14.phx.gbl...
> What is your suggested changes in order to port the following code segment
> to the Windows platform? AF_UNIX? I don't understand these definitions.
>
> int
> gaim_remote_session_connect(int session)
> {
> gint fd;
> uid_t stored_uid, euid;
> struct sockaddr_un saddr;
>
> if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1)
> {
> saddr.sun_family = AF_UNIX;
> stored_uid = getuid();
> euid = geteuid();
> setuid(euid);
> sprintf(saddr.sun_path, "%s/gaim_%s.%d",
> g_get_tmp_dir(), g_get_user_name(), session);
> setreuid(stored_uid, euid);
>
> if (connect(fd, (struct sockaddr *) &saddr, sizeof (saddr)) != -1)
> return fd;
> }
>
> close(fd);
>
> return -1;
> }
>
>
- Next message: Ivan Starr: "What's the best way to determine effective file creation/write rights??"
- Previous message: Scott McPhillips [MVP]: "Re: Threads and Socket Design problem"
- In reply to: Jim Jones: "Help porting UNIX Socket Based App"
- Next in thread: Joseph M. Newcomer: "Re: Help porting UNIX Socket Based App"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|