如何在服务中获得客户端的IP?

yizhao 2002-12-03 01:44:58
我写了个服务如下,调用TMIB,但是获得为空

#include <fml32.h>
#include <tpadm.h>
#include <stdio.h>
#include <ctype.h>
#include <atmi.h> /* TUXEDO Header File */
#include <userlog.h> /* TUXEDO Header File */

/* tpsvrinit is executed when a server is booted, before it begins
processing requests. It is not necessary to have this function.
Also available is tpsvrdone (not used in this example), which is
called at server shutdown time.
*/

#if defined(__STDC__) || defined(__cplusplus)
tpsvrinit(int argc, char *argv[])
#else
tpsvrinit(argc, argv)
int argc;
char **argv;
#endif
{
/* Some compilers warn if argc and argv aren't used. */
argc = argc;
argv = argv;

/* userlog writes to the central TUXEDO message log */
userlog("Welcome to the simple server");
return(0);
}

/* This function performs the actual service requested by the client.
Its argument is a structure containing among other things a pointer
to the data buffer, and the length of the data buffer.
*/

#ifdef __cplusplus
extern "C"
#endif
void
#if defined(__STDC__) || defined(__cplusplus)
MYMIB(TPSVCINFO *rqst)
#else
MYMIB(rqst)
TPSVCINFO *rqst;
#endif
{
long blen;
FBFR32 *ibuf;

char mystr[1000]="";

ibuf = (FBFR32 *)tpalloc("FML32", NULL, 10000);
userlog("0");
Fchg32(ibuf, TA_OPERATION, 0, "GET", 0);
Fchg32(ibuf, TA_CLASS, 0, "T_CLIENT", 0);
userlog("1");
Fprint32(ibuf);

userlog("2");
if (tpcall(".TMIB", (char *)ibuf, 0, (char **)&ibuf, &blen, 0) == -1)
{
printf("tpcall(.TMIB) failed: %s\n", tpstrerror(tperrno));
Fprint32(ibuf);
userlog("call error");
tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
}
userlog("3");
/* if (tpadmcall(ibuf, &ibuf, 0) == -1)
{
printf("tpcadmcall() failed: %s\n", tpstrerror(tperrno));
Fprint32(ibuf);
return(-1);
}*/


Fget32(ibuf,TA_NADDR,0,mystr,0);

userlog("%s",ibuf);

tpfree((char *)ibuf);

tpterm();

tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
}


谁能解决一下这个问题?
...全文
42 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoyebing 2002-12-27
  • 打赏
  • 举报
回复
request.getRemoteAddr()
request.getRemoteHost()
request.getRemoteUser()

查查request提供的方法就可以了
armyshu 2002-12-27
  • 打赏
  • 举报
回复
getRemoteAdrr()方法调用
ZEROSolid 2002-12-17
  • 打赏
  • 举报
回复
靠!大哥,你把这么一堆代码写上去让谁看啊!
你是否应该总结一下问题所在,写得精炼一点
这样才会得到比较有价值的答复
nullhue 2002-12-12
  • 打赏
  • 举报
回复
让客户端把他的IP地址发过来.
这要看你手段了.
seani 2002-12-06
  • 打赏
  • 举报
回复
我也想知道,帮你up

1,219

社区成员

发帖
与我相关
我的任务
社区描述
企业软件 中间件技术
社区管理员
  • 中间件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧