> This page is for Excel.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://ibkrcampus.com/docs/llms.txt.

# DDE Socket Bridge

The DDE Socket Bridge is an essential component of the Excel DDE API library. This governs all communication between the Trader Workstation and Excel using the JDDE implementation.

## Steps to launch DDE Socket Bridge

1. Launch Trader Workstation or IB Gateway
2. Open the Windows File Explorer
3. Navigate to `C:\TWS API\samples\DdeSocketBridge`
4. Double click the file, runDdeSocketBridge.bat. It may just be labeled as runDdeSocketBridge on your computer.
5. There should be two popup windows that appear.
   * The first will be a black command prompt window. You may see a few lines stating you are connected, and a few stating "Error… data farm connection is OK." These "errors" are only notifications, and should not cause concern.
   * You will also see a small java window. This will list the service name, host, port, clientId, and you should see "Connected!". If you see "Disconnected" instead, you may need to Configure Your Socket Bridge.
6. Assuming your socket bridge is showing "Connected!" then you can navigate to `C:\TWS API\samples\Excel` and open the  TwsDde.xls file sample.

> **Warning**
>
> Excel DDE users must have installed [Java 25](https://www.oracle.com/java/technologies/downloads/#jdk25-windows) in order to launch DDE Socket Bridge. If Java 25 is not installed, the runDdeSocketBridge.bat Windows Command Prompt (CMD) will open and close.

---

## Customize DDE Socket Bridge Behavior

For various reasons, you may find the need to modify the connection values used for the DDE Socket Bridge.

You are able to modify the ClientID, Host IP, Socket Port, and Service Name.

#### Configure the Connecting ClientId

1. Launch Trader Workstation or IB Gateway
2. Open the Windows File Explorer
3. Navigate to `C:\TWS API\samples\DdeSocketBridge`
4. Right click the "runDdeSocketBridge.bat" file.
5. Click **Edit** from the list. This will open a new Notepad window.
   * NOTE: Windows 11 users may need to choose "Show more options" first.
6. On the third line after "DdeSocketBridge.jar" **add -c** followed by whichever ClientID you wish to connect with.

```
echo off
if not exist "DdeSocketBridge.jar" goto :error
java -Djava.library.path=.\src\main\resources -jar DdeSocketBridge.jar -c12345
goto :end
:error
echo DdeSocketBridge.jar is not found
:end
```

#### Configure the Connecting Socket Port

1. Launch Trader Workstation or IB Gateway
2. Open the Windows File Explorer
3. Navigate to `C:\TWS API\samples\DdeSocketBridge`
4. Right click the "runDdeSocketBridge.bat" file.
5. Click **Edit** from the list. This will open a new Notepad window.
   * NOTE: Windows 11 users may need to choose "Show more options" first.
6. On the third line after "DdeSocketBridge.jar" **add -p** followed by whichever socket port you have specified in TWS or IB Gateway.

The default ports supplied by Interactive Brokers are as follows:

* TWS Live Account: 7496 (Socket Bridge's default value)
* TWS Paper Account: 7497
* IB Gateway Live Account: 4001
* IB Gateway Paper Account: 4002

```
echo off
if not exist "DdeSocketBridge.jar" goto :error
java -Djava.library.path=.\src\main\resources -jar DdeSocketBridge.jar -p7497
goto :end
:error
echo DdeSocketBridge.jar is not found
:end
```

#### Configure the Connecting Host IP Address

1. Launch Trader Workstation or IB Gateway
2. Open the Windows File Explorer
3. Navigate to `C:\TWS API\samples\DdeSocketBridge`
4. Right click the "runDdeSocketBridge.bat" file.
5. Click **Edit** from the list. This will open a new Notepad window.
   * NOTE: Windows 11 users may need to choose "Show more options" first.
6. On the third line after "DdeSocketBridge.jar" **add -h** followed by whichever IP Address you need to connect to.

NOTE: Be sure this IP address matches the location of your Trader Workstation. Also be sure that the Socket Bridge's IP matches where Excel is being hosted.

```
echo off
if not exist "DdeSocketBridge.jar" goto :error
java -Djava.library.path=.\src\main\resources -jar DdeSocketBridge.jar -h123.123.123.123
goto :end
:error
echo DdeSocketBridge.jar is not found
:end
```

#### Configure the Connecting Service Name

1. Launch Trader Workstation or IB Gateway
2. Open the Windows File Explorer
3. Navigate to `C:\TWS API\samples\DdeSocketBridge`
4. Right click the "runDdeSocketBridge.bat" file.
5. Click **Edit** from the list. This will open a new Notepad window.
   * NOTE: Windows 11 users may need to choose "Show more options" first.
6. On the third line after "DdeSocketBridge.jar" **add -s** followed by whichever Service name you wish to use in Excel.

NOTE: Be sure on each page of your connected DDE that you match the User Name cell with what is listed here.

```
echo off
if not exist "DdeSocketBridge.jar" goto :error
java -Djava.library.path=.\src\main\resources -jar DdeSocketBridge.jar -sExcelsior
goto :end
:error
echo DdeSocketBridge.jar is not found
:end
```