node.js中的http.createserver和net.createserver一起

问题描述

我在节点js中有2个脚本。一种使用“ http”,另一种使用“ net”。我想将这些脚本一起制作成一个脚本。我的“ http”脚本如下:

import React from 'react';
import { Provider } from 'react-native-paper';
import App from './src';
import { theme } from './src/core/theme';
import { NavigationContainer } from '@react-navigation/native';
import Drawer from './src/components/Drawer';
export default () => {
  
  return (
    <NavigationContainer>
      <Drawer />
    </NavigationContainer>
  );
};

'net'脚本:

const http = require('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req,res) => {
 console.log(req.headers);
 res.statusCode = 200;
 res.end('<html><body><h1>Hello,World!</h1></body></html>');
})
server.listen(port,hostname);

我的目的是在启动“ http”脚本后运行“ net”脚本。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)