如何在服务中获得客户端的IP?
我写了个服务如下,调用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);
}
谁能解决一下这个问题?
#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);
}
谁能解决一下这个问题?
...全文
相关推荐
Java面试之如何获取客户端真实IP
主要给大家介绍了关于Java面试之如何获取客户端真实IP的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用Java具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
《widows服务》知识点总结.pdf
《widows服务》知识点总结.pdf
php 禁止国内IP访问网站
PHP写的禁止国内IP访问网站,适合外贸网站。资源包括了代码和内网IP列表。
内网ip使用DTU gprs传输功能
内网ip使用DTU 实现gprs传输功能测试
webService调取IP所在地,以及获得客户端真实IP
webService调取IP所在地,以及获得客户端真实IP


