public static IRubyObject getservbyname(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
String name = args[0].convertToString().toString();
String proto = args.length == 1 ? "tcp" : args[1].convertToString().toString();
Service service = Service.getServiceByName(name, proto);
int port;
if (service != null) {
port = service.getPort();
} else {
// MRI behavior: try to convert the name string to port directly
try {