2022-10-21 17:16:00 +02:00
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home ](./index.md ) > [bitburner ](./bitburner.md ) > [NS ](./bitburner.ns.md ) > [scan ](./bitburner.ns.scan.md )
## NS.scan() method
Get the list of servers connected to a server.
2023-02-11 19:18:50 +01:00
**Signature:**
2022-10-21 17:16:00 +02:00
```typescript
scan(host?: string): string[];
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
2023-02-11 19:18:50 +01:00
| host | string | _(Optional)_ Optional. Hostname of the server to scan, default to current server. |
2022-10-21 17:16:00 +02:00
2023-02-11 19:18:50 +01:00
**Returns:**
2022-10-21 17:16:00 +02:00
string\[\]
2022-11-20 18:07:22 +01:00
Returns an array of hostnames.
2022-10-21 17:16:00 +02:00
## Remarks
RAM cost: 0.2 GB
Returns an array containing the hostnames of all servers that are one node way from the specified target server. The hostnames in the returned array are strings.
2023-04-28 20:19:30 +02:00
## Example
2022-11-20 18:07:22 +01:00
2023-04-28 20:19:30 +02:00
```js
2022-11-20 18:07:22 +01:00
// All servers that are one hop from the current server.
ns.tprint("Neighbors of current server.");
let neighbor = ns.scan();
for (let i = 0; i < neighbor.length ; i + + ) {
ns.tprint(neighbor[i]);
}
// All neighbors of n00dles.
const target = "n00dles";
neighbor = ns.scan(target);
ns.tprintf("Neighbors of %s.", target);
for (let i = 0; i < neighbor.length ; i + + ) {
ns.tprint(neighbor[i]);
}
```