areusch commented on a change in pull request #7876: URL: https://github.com/apache/tvm/pull/7876#discussion_r663210300
########## File path: apps/ios_rpc/tvmrpc/RPCServer.mm ########## @@ -0,0 +1,815 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file ViewController.mm + */ + +#import "RPCServer.h" + +#include <tvm/runtime/packed_func.h> +#include <tvm/runtime/registry.h> + +#include <random> +#include <string> + +// To get device WiFi IP +#include <arpa/inet.h> +#include <ifaddrs.h> +#include <netinet/in.h> +#include <sys/socket.h> + +// TVM internal header to access Magic keys like kRPCMagic and others +#include "../../../src/runtime/rpc/rpc_endpoint.h" + +namespace tvm { +namespace runtime { + +/*! + * \brief Message handling function for event driven server. + * + * \param in_bytes The incoming bytes. + * \param event_flag 1: read_available, 2: write_avaiable. + * \return State flag. + * 1: continue running, no need to write, + * 2: need to write + * 0: shutdown + */ +using FEventHandler = PackedFunc; + +/*! + * \brief Create a server event handler. + * + * \param outputStream The output stream used to send outputs. + * \param name The name of the server. + * \param remote_key The remote key + * \return The event handler. + */ +FEventHandler CreateServerEventHandler(NSOutputStream* outputStream, std::string name, + std::string remote_key) { + const PackedFunc* event_handler_factor = Registry::Get("rpc.CreateEventDrivenServer"); Review comment: nit: event_handler_factory -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
