|
Hello Jorge, - Here's an RPG/IV example of the getservbyport() function: H bnddir( 'QC2LE' ) ** D getservbyport pr * extproc( 'getservbyport' ) D port 10i 0 value D protocol * value options( *string ) ** D servent ds based( p_servent ) D s_name * D s_aliases * D port 10i 0 D s_proto * ** D idx s 10i 0 D name s 128a D protocol s 128a D p_aliases s * dim( 12 ) based( s_aliases ) D aliases s 128a dim( %elem( p_aliases )) ** /free p_servent = getservbyport( 443: *null ); if p_servent <> *null; name = %str( s_name ); protocol = %str( s_proto ); for idx = 1 to %elem( p_aliases ); if p_aliases(idx) = *null; leave; endif; aliases(idx) = %str( p_aliases(idx)); endfor; endif; p_servent = getservbyport( 443: 'udp' ); if p_servent <> *null; name = %str( s_name ); protocol = %str( s_proto ); for idx = 1 to %elem( p_aliases ); if p_aliases(idx) = *null; leave; endif; aliases(idx) = %str( p_aliases(idx)); endfor; endif; *inlr = *on; return; /end-free The first call returns the first server registered to the specified port. The second call returns the service name for the specified port's 'udp' protocol entry. If you need to call the getservbyport() function repeatedly, the setservent() and endservent() functions allow you to control when the service database file is opened and closed, leaving it open for the getservbyport() calls. The getservent() function enables you to retrieve a sequential list of the servers in the service database. Best regards, Carsten Flensburg ----- Original Message ----- From: <jmoreno@xxxxxxxxxxxxxxxx> To: <Midrange-L@xxxxxxxxxxxx> Sent: Wednesday, June 16, 2004 4:49 PM Subject: How to retrieve TCP/IP service (local port name) by local portnumber > I am not sure how to do this. > Is there any way to retrieve the TCP/IP service (local port name) > associated to a local port number ? > > Just like int the command WRKSRVTBLE > > Is there an API for this ? ########################################### This message has been scanned by F-Secure Anti-Virus for Internet Mail. For more information, connect to http://www.F-Secure.com/
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.