![]() |
![]() |
#1 |
高级会员
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 注册: 08年04月11日
来自: 盘丝洞
帖子: 311
声望力: 20
声望:
50
![]() 现金:29两梁山币
资产:1245两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
支持tcpip协议的LTP
同时支持to mud 和 to bbs 修改自rongg的代码 对to mud 模式没有任何问题 在to bbs 模式下不支持back space和Esc两个键 另外在 to bbs 的时候甚至可以用cterm,就是用cterm发文章的时候显示比较奇怪 /****************cmd**************/ // /cmds/arch/tcpip.c // 支持tcpip协议的Lpc telnet proxy // 现在只有一点小问题了 :)) // ReWrite by akuma@xo // CopyRight 2000 Xo_Group // 这个是命令,真正用用的是tcpip.c的body #define TCP_BODY "/adm/daemons/tcpip" inherit F_CLEAN_UP; void create() { seteuid(getuid()); } int main(object me,string arg) { object ob; object linkob; object *tcpip; me=this_player(); if( strsrch(arg," ")==-1) arg+=" 23"; tcpip=children(TCP_BODY); ob=new(TCP_BODY); linkob = me->query_temp("link_ob"); exec(ob,me); ob->do_telnet(arg); ob->do_command(""); "/cmds/usr/quit"->main(me); return 1; } /**************body********************/ // /system/daemon/network/tcpip.c // 支持tcpip协议的Lpc telnet proxy // 现在只有一点小问题了 :)) // ReWrite by akuma@xo // CopyRight 2000 Xo_Group #include < net/socket.h > #include < net/socket_errors.h > inherit F_DBASE; int my_socket,socket1,socket2; int do_telnet(string arg); void tell_me(string str); int write_message(string arg); void create() { } void receive_message(string type, string str) { if( type!= "write"&&type!="tcpip" ) return; receive(str); } void tell_me(string str) { message("tcpip",str,this_object()); } void do_command(string cmd) { write_message(cmd); get_char("do_command",0); } int do_telnet(string arg) { int err; my_socket = socket_create( STREAM, "in_read_callback","in_close_callbackk" ); if ( my_socket < 0 ) { tell_me( "无法生成新的Socket,telnet进程被终止。\n" ); return 1; } err = socket_connect( my_socket, arg , "read_callback","write_callback"); if( err==EESUCCESS ) { tell_me("正在连接 " + arg + "。。。\n"); } else { tell_me("无法连接到 " + arg + ",再见!\n"); destruct(this_object()); } return 1; } int in_close_callback(int fd) { destruct(this_object()); } int close_socket() { if( socket_close(my_socket) ) { tell_me("正常关闭Socket。\n"); } else tell_me("无法关闭该Socket。\n"); return 1; } void read_callback(int fd, mixed message) { message("tcpip",(string) message,this_object()); } int write_message(string arg) { socket_write(my_socket,arg); return 1; } void net_dead() { remove_call_out("time_out"); call_out( "time_out", 10 ); } void time_out() { close_socket(); destruct(this_object()); } |
![]() |
![]() |