javac 1.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- javac-1.1.5/LICENSE +21 -0
- javac-1.1.5/PKG-INFO +21 -0
- javac-1.1.5/README.md +0 -0
- javac-1.1.5/javac/__init__.py +28 -0
- javac-1.1.5/javac/calculator.py +104 -0
- javac-1.1.5/javac/chatting application.py +117 -0
- javac-1.1.5/javac/current date and time.py +78 -0
- javac-1.1.5/javac/even odd.py +82 -0
- javac-1.1.5/javac/multicast socket.py +84 -0
- javac-1.1.5/javac/prime no.py +100 -0
- javac-1.1.5/javac.egg-info/PKG-INFO +21 -0
- javac-1.1.5/javac.egg-info/SOURCES.txt +14 -0
- javac-1.1.5/javac.egg-info/dependency_links.txt +1 -0
- javac-1.1.5/javac.egg-info/top_level.txt +1 -0
- javac-1.1.5/setup.cfg +4 -0
- javac-1.1.5/setup.py +26 -0
javac-1.1.5/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chirag Vishwakarma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
javac-1.1.5/PKG-INFO
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: javac
|
|
3
|
+
Version: 1.1.5
|
|
4
|
+
Summary: Teri Maa ne bhoot ke sath suhagrat rachai thi woh bhoot huh mein
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: kya dekh rha hai luvday
|
|
7
|
+
Author-email: xyz@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: author-email
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: license
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: requires-python
|
|
21
|
+
Dynamic: summary
|
javac-1.1.5/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
def show_codes(filename: str = None):
|
|
4
|
+
"""
|
|
5
|
+
Displays code from the scikit-learrnn package.
|
|
6
|
+
- If filename is given (without .py), shows that file's code.
|
|
7
|
+
- If no filename is given, shows all .py files.
|
|
8
|
+
"""
|
|
9
|
+
base_path = os.path.dirname(__file__)
|
|
10
|
+
files = [f for f in os.listdir(base_path) if f.endswith(".py") and f != "__init__.py"]
|
|
11
|
+
|
|
12
|
+
if filename:
|
|
13
|
+
file_path = os.path.join(base_path, f"{filename}.py")
|
|
14
|
+
if os.path.exists(file_path):
|
|
15
|
+
print(f"\n=== Showing {filename}.py ===\n")
|
|
16
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
17
|
+
print(f.read())
|
|
18
|
+
else:
|
|
19
|
+
print(f"\n❌ File '{filename}.py' not found in scikit-learrnn.\n")
|
|
20
|
+
print("Available files:")
|
|
21
|
+
for f in files:
|
|
22
|
+
print("•", f.replace(".py", ""))
|
|
23
|
+
else:
|
|
24
|
+
print("\nAll practical codes in scikit-learrnn:\n")
|
|
25
|
+
for f in files:
|
|
26
|
+
print(f"\n=== {f} ===\n")
|
|
27
|
+
with open(os.path.join(base_path, f), "r", encoding="utf-8") as file:
|
|
28
|
+
print(file.read())
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
|
|
2
|
+
#calculator
|
|
3
|
+
|
|
4
|
+
import java.net.*;
|
|
5
|
+
class RPCServer {
|
|
6
|
+
DatagramSocket ds;
|
|
7
|
+
DatagramPacket dp;
|
|
8
|
+
String st1, methodName, result;
|
|
9
|
+
int val1, val2;
|
|
10
|
+
RPCServer() {
|
|
11
|
+
try {
|
|
12
|
+
ds = new DatagramSocket(1200);
|
|
13
|
+
byte b[] = new byte[1024];
|
|
14
|
+
System.out.println("RPC Server is running on port 1200...\n");
|
|
15
|
+
while (true) {
|
|
16
|
+
dp = new DatagramPacket(b, b.length);
|
|
17
|
+
ds.receive(dp); // receive client request
|
|
18
|
+
st1 = new String(dp.getData(), 0, dp.getLength());
|
|
19
|
+
if (st1.equalsIgnoreCase("q")) {
|
|
20
|
+
System.out.println("Server Stopped.");
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
String arr[] = st1.split(" ");
|
|
24
|
+
methodName = arr[0];
|
|
25
|
+
val1 = Integer.parseInt(arr[1]);
|
|
26
|
+
val2 = Integer.parseInt(arr[2]);
|
|
27
|
+
if (methodName.equalsIgnoreCase("sub"))
|
|
28
|
+
result = String.valueOf(sub(val1, val2));
|
|
29
|
+
else if (methodName.equalsIgnoreCase("mul"))
|
|
30
|
+
result = String.valueOf(mul(val1, val2));
|
|
31
|
+
else if (methodName.equalsIgnoreCase("div"))
|
|
32
|
+
result = String.valueOf(div(val1, val2));
|
|
33
|
+
else if (methodName.equalsIgnoreCase("add"))
|
|
34
|
+
result = String.valueOf(add(val1, val2));
|
|
35
|
+
else
|
|
36
|
+
result = "Invalid Method";
|
|
37
|
+
byte b1[] = result.getBytes();
|
|
38
|
+
DatagramPacket dp1 = new DatagramPacket(
|
|
39
|
+
b1,
|
|
40
|
+
b1.length,
|
|
41
|
+
dp.getAddress(),
|
|
42
|
+
dp.getPort()
|
|
43
|
+
);
|
|
44
|
+
ds.send(dp1);
|
|
45
|
+
System.out.println("Client Request: " + st1);
|
|
46
|
+
System.out.println("Result Sent: " + result + "\n");
|
|
47
|
+
}
|
|
48
|
+
ds.close();
|
|
49
|
+
} catch (Exception e) {
|
|
50
|
+
e.printStackTrace();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
public int sub(int a, int b) {
|
|
54
|
+
return a - b;
|
|
55
|
+
}
|
|
56
|
+
public int add(int a, int b) {
|
|
57
|
+
return a + b;
|
|
58
|
+
}
|
|
59
|
+
public int mul(int a, int b) {
|
|
60
|
+
return a * b;
|
|
61
|
+
}
|
|
62
|
+
public int div(int a, int b) {
|
|
63
|
+
return a / b;
|
|
64
|
+
}
|
|
65
|
+
public static void main(String args[]) {
|
|
66
|
+
new RPCServer();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
##
|
|
72
|
+
import java.net.*;
|
|
73
|
+
class RPCClient {
|
|
74
|
+
RPCClient() {
|
|
75
|
+
try {
|
|
76
|
+
DatagramSocket ds = new DatagramSocket(); // create socket
|
|
77
|
+
InetAddress ia = InetAddress.getLocalHost();
|
|
78
|
+
BufferedReader br = new BufferedReader(
|
|
79
|
+
new InputStreamReader(System.in)
|
|
80
|
+
);
|
|
81
|
+
System.out.println("Enter method name and parameters like add 3 4:");
|
|
82
|
+
String s = br.readLine(); // take input
|
|
83
|
+
byte b[] = s.getBytes();
|
|
84
|
+
DatagramPacket dp = new DatagramPacket(
|
|
85
|
+
b,
|
|
86
|
+
b.length,
|
|
87
|
+
ia,
|
|
88
|
+
1200
|
|
89
|
+
);
|
|
90
|
+
ds.send(dp); // send request
|
|
91
|
+
byte b1[] = new byte[1024];
|
|
92
|
+
dp = new DatagramPacket(b1, b1.length);
|
|
93
|
+
ds.receive(dp); // receive response
|
|
94
|
+
String s2 = new String(dp.getData(), 0, dp.getLength());
|
|
95
|
+
System.out.println("\nResult = " + s2);
|
|
96
|
+
ds.close();
|
|
97
|
+
} catch (Exception e) {
|
|
98
|
+
e.printStackTrace();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
public static void main(String args[]) {
|
|
102
|
+
new RPCClient();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#chatting application
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import java.net.*;
|
|
5
|
+
import java.io.*;
|
|
6
|
+
|
|
7
|
+
class ChatServer {
|
|
8
|
+
|
|
9
|
+
public static void main(String args[]) {
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
// Create server socket on port 8000
|
|
13
|
+
ServerSocket ss = new ServerSocket(8000);
|
|
14
|
+
System.out.println("Waiting for client to connect...");
|
|
15
|
+
|
|
16
|
+
// Accept client connection
|
|
17
|
+
Socket s = ss.accept();
|
|
18
|
+
System.out.println("Client connected!");
|
|
19
|
+
|
|
20
|
+
// Read from client
|
|
21
|
+
BufferedReader br = new BufferedReader(
|
|
22
|
+
new InputStreamReader(s.getInputStream()));
|
|
23
|
+
|
|
24
|
+
// Read from server keyboard
|
|
25
|
+
BufferedReader keyboard = new BufferedReader(
|
|
26
|
+
new InputStreamReader(System.in));
|
|
27
|
+
|
|
28
|
+
// Send to client
|
|
29
|
+
DataOutputStream out =
|
|
30
|
+
new DataOutputStream(s.getOutputStream());
|
|
31
|
+
|
|
32
|
+
String receive, send;
|
|
33
|
+
|
|
34
|
+
// Continuous chat
|
|
35
|
+
while ((receive = br.readLine()) != null) {
|
|
36
|
+
|
|
37
|
+
// Display client message
|
|
38
|
+
System.out.println("Client says: " + receive);
|
|
39
|
+
|
|
40
|
+
// Type reply from server
|
|
41
|
+
send = keyboard.readLine();
|
|
42
|
+
|
|
43
|
+
// Send reply
|
|
44
|
+
out.writeBytes(send + "\n");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Close all connections
|
|
48
|
+
br.close();
|
|
49
|
+
keyboard.close();
|
|
50
|
+
out.close();
|
|
51
|
+
s.close();
|
|
52
|
+
ss.close();
|
|
53
|
+
|
|
54
|
+
} catch (Exception e) {
|
|
55
|
+
e.printStackTrace();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
import java.net.*;
|
|
63
|
+
import java.io.*;
|
|
64
|
+
|
|
65
|
+
class ChatClient {
|
|
66
|
+
|
|
67
|
+
public static void main(String args[]) {
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
// Connect to server
|
|
71
|
+
Socket s = new Socket("localhost", 8000);
|
|
72
|
+
System.out.println("Connected to server!");
|
|
73
|
+
|
|
74
|
+
// Keyboard input
|
|
75
|
+
BufferedReader keyboard = new BufferedReader(
|
|
76
|
+
new InputStreamReader(System.in));
|
|
77
|
+
|
|
78
|
+
// Read from server
|
|
79
|
+
BufferedReader in = new BufferedReader(
|
|
80
|
+
new InputStreamReader(s.getInputStream()));
|
|
81
|
+
|
|
82
|
+
// Send to server
|
|
83
|
+
DataOutputStream out =
|
|
84
|
+
new DataOutputStream(s.getOutputStream());
|
|
85
|
+
|
|
86
|
+
String msg, reply;
|
|
87
|
+
|
|
88
|
+
System.out.println("Type STOP to end chat");
|
|
89
|
+
|
|
90
|
+
// Continuous chat
|
|
91
|
+
while (true) {
|
|
92
|
+
|
|
93
|
+
// Send message
|
|
94
|
+
msg = keyboard.readLine();
|
|
95
|
+
out.writeBytes(msg + "\n");
|
|
96
|
+
|
|
97
|
+
if (msg.equalsIgnoreCase("STOP"))
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
// Receive reply
|
|
101
|
+
reply = in.readLine();
|
|
102
|
+
System.out.println("Server says: " + reply);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Close all resources
|
|
106
|
+
keyboard.close();
|
|
107
|
+
in.close();
|
|
108
|
+
out.close();
|
|
109
|
+
s.close();
|
|
110
|
+
|
|
111
|
+
} catch (Exception e) {
|
|
112
|
+
e.printStackTrace();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
##save as InterDate.java
|
|
2
|
+
|
|
3
|
+
import java.rmi.Remote;
|
|
4
|
+
import java.rmi.RemoteException;
|
|
5
|
+
|
|
6
|
+
public interface InterDate extends Remote {
|
|
7
|
+
|
|
8
|
+
// Remote method must throw RemoteException
|
|
9
|
+
String display() throws RemoteException;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
|
|
15
|
+
##save as ClientDate.java
|
|
16
|
+
import java.rmi.Naming;
|
|
17
|
+
|
|
18
|
+
public class ClientDate {
|
|
19
|
+
|
|
20
|
+
public static void main(String[] args) {
|
|
21
|
+
try {
|
|
22
|
+
// Lookup remote object
|
|
23
|
+
InterDate stub = (InterDate) Naming.lookup("rmi://localhost:1099/DS");
|
|
24
|
+
|
|
25
|
+
// Call remote method
|
|
26
|
+
String date = stub.display();
|
|
27
|
+
|
|
28
|
+
// Display result
|
|
29
|
+
System.out.println("Current Date and Time from Server:");
|
|
30
|
+
System.out.println(date);
|
|
31
|
+
}
|
|
32
|
+
catch (Exception e) {
|
|
33
|
+
e.printStackTrace();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
## save as ServerDate
|
|
38
|
+
import java.rmi.Naming;
|
|
39
|
+
import java.rmi.RemoteException;
|
|
40
|
+
import java.rmi.registry.LocateRegistry;
|
|
41
|
+
import java.rmi.server.UnicastRemoteObject;
|
|
42
|
+
import java.util.Date;
|
|
43
|
+
|
|
44
|
+
public class ServerDate extends UnicastRemoteObject implements InterDate {
|
|
45
|
+
|
|
46
|
+
// Constructor
|
|
47
|
+
protected ServerDate() throws RemoteException {
|
|
48
|
+
super();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Implementation of remote method
|
|
52
|
+
public String display() throws RemoteException {
|
|
53
|
+
return new Date().toString();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Main method
|
|
57
|
+
public static void main(String[] args) {
|
|
58
|
+
try {
|
|
59
|
+
// Start RMI registry at port 1099
|
|
60
|
+
LocateRegistry.createRegistry(1099);
|
|
61
|
+
|
|
62
|
+
// Create remote object
|
|
63
|
+
ServerDate server = new ServerDate();
|
|
64
|
+
|
|
65
|
+
// Bind object to registry
|
|
66
|
+
Naming.rebind("rmi://localhost:1099/DS", server);
|
|
67
|
+
|
|
68
|
+
System.out.println("Server is running and object registered...");
|
|
69
|
+
}
|
|
70
|
+
catch (Exception e) {
|
|
71
|
+
e.printStackTrace();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
run javac *.java
|
|
77
|
+
java ServerDate
|
|
78
|
+
java ClientDate
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
## even odd
|
|
2
|
+
|
|
3
|
+
import java.io.*;
|
|
4
|
+
import java.net.*;
|
|
5
|
+
public class prac4server{
|
|
6
|
+
public static void main(String args[]) {
|
|
7
|
+
try {
|
|
8
|
+
DatagramSocket ds = new DatagramSocket(2000);
|
|
9
|
+
byte b[] = new byte[1024];
|
|
10
|
+
DatagramPacket dp = new DatagramPacket(b, b.length);
|
|
11
|
+
ds.receive(dp);
|
|
12
|
+
// Convert received bytes into string
|
|
13
|
+
String str = new String(dp.getData(), 0, dp.getLength());
|
|
14
|
+
System.out.println("Received number: " + str);
|
|
15
|
+
// Convert string to integer
|
|
16
|
+
int a = Integer.parseInt(str);
|
|
17
|
+
String s;
|
|
18
|
+
// Check even or odd
|
|
19
|
+
if (a % 2 == 0)
|
|
20
|
+
s = "Number is Even";
|
|
21
|
+
else
|
|
22
|
+
s = "Number is Odd";
|
|
23
|
+
// Convert result into byte array
|
|
24
|
+
byte b1[] = s.getBytes();
|
|
25
|
+
// Send result back to client
|
|
26
|
+
DatagramPacket dp1 = new DatagramPacket(
|
|
27
|
+
b1,
|
|
28
|
+
b1.length,
|
|
29
|
+
dp.getAddress(),
|
|
30
|
+
dp.getPort()
|
|
31
|
+
);
|
|
32
|
+
ds.send(dp1);
|
|
33
|
+
ds.close();
|
|
34
|
+
} catch (Exception e) {
|
|
35
|
+
e.printStackTrace();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
##
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
Folder highlights
|
|
45
|
+
Java programs implement a UDP client-server check to determine if an entered number is even or odd.
|
|
46
|
+
|
|
47
|
+
import java.io.*;
|
|
48
|
+
import java.net.*;
|
|
49
|
+
public class prac4client {
|
|
50
|
+
public static void main(String args[]) {
|
|
51
|
+
try {
|
|
52
|
+
// Create socket on port 1000
|
|
53
|
+
DatagramSocket ds = new DatagramSocket(1000);
|
|
54
|
+
// Take input from user
|
|
55
|
+
BufferedReader br = new BufferedReader(
|
|
56
|
+
new InputStreamReader(System.in)
|
|
57
|
+
);
|
|
58
|
+
System.out.println("Enter a number:");
|
|
59
|
+
String num = br.readLine();
|
|
60
|
+
// Convert input to bytes
|
|
61
|
+
byte b[] = num.getBytes();
|
|
62
|
+
// Create packet to send to server (port 2000)
|
|
63
|
+
DatagramPacket dp = new DatagramPacket(
|
|
64
|
+
b,
|
|
65
|
+
b.length,
|
|
66
|
+
InetAddress.getLocalHost(),
|
|
67
|
+
2000
|
|
68
|
+
);
|
|
69
|
+
ds.send(dp);
|
|
70
|
+
// Receive response from server
|
|
71
|
+
byte b1[] = new byte[1024];
|
|
72
|
+
DatagramPacket dp1 = new DatagramPacket(b1, b1.length);
|
|
73
|
+
ds.receive(dp1);
|
|
74
|
+
// Convert response to string
|
|
75
|
+
String str = new String(dp1.getData(), 0, dp1.getLength());
|
|
76
|
+
System.out.println("Server Response: " + str);
|
|
77
|
+
ds.close();
|
|
78
|
+
} catch (Exception e) {
|
|
79
|
+
e.printStackTrace();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import java.net.*;
|
|
2
|
+
|
|
3
|
+
public class BroadcastClient {
|
|
4
|
+
|
|
5
|
+
public static final int PORT = 1234;
|
|
6
|
+
|
|
7
|
+
public static void main(String[] args) throws Exception {
|
|
8
|
+
|
|
9
|
+
InetAddress group = InetAddress.getByName("239.1.2.3");
|
|
10
|
+
|
|
11
|
+
// Create socket properly (modern way)
|
|
12
|
+
MulticastSocket socket = new MulticastSocket(null);
|
|
13
|
+
socket.setReuseAddress(true);
|
|
14
|
+
socket.bind(new InetSocketAddress(PORT));
|
|
15
|
+
|
|
16
|
+
// Get network interface
|
|
17
|
+
NetworkInterface networkInterface =
|
|
18
|
+
NetworkInterface.getByInetAddress(InetAddress.getLocalHost());
|
|
19
|
+
|
|
20
|
+
// Join multicast group
|
|
21
|
+
socket.joinGroup(new InetSocketAddress(group, PORT), networkInterface);
|
|
22
|
+
|
|
23
|
+
System.out.println("Client started. Waiting for messages...");
|
|
24
|
+
|
|
25
|
+
byte[] buffer = new byte[1024];
|
|
26
|
+
|
|
27
|
+
while (true) {
|
|
28
|
+
DatagramPacket packet =
|
|
29
|
+
new DatagramPacket(buffer, buffer.length);
|
|
30
|
+
|
|
31
|
+
socket.receive(packet);
|
|
32
|
+
|
|
33
|
+
String message = new String(
|
|
34
|
+
packet.getData(), 0, packet.getLength());
|
|
35
|
+
|
|
36
|
+
System.out.println("Message received from "
|
|
37
|
+
+ packet.getAddress()
|
|
38
|
+
+ " : " + message);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
###
|
|
45
|
+
import java.net.*;
|
|
46
|
+
|
|
47
|
+
public class BroadcastServer {
|
|
48
|
+
|
|
49
|
+
public static final int PORT = 1234;
|
|
50
|
+
|
|
51
|
+
public static void main(String[] args) throws Exception {
|
|
52
|
+
|
|
53
|
+
// Multicast group address
|
|
54
|
+
InetAddress group = InetAddress.getByName("239.1.2.3");
|
|
55
|
+
|
|
56
|
+
// Create multicast socket
|
|
57
|
+
MulticastSocket socket = new MulticastSocket();
|
|
58
|
+
|
|
59
|
+
// Optional: keep multicast within local network
|
|
60
|
+
socket.setTimeToLive(1);
|
|
61
|
+
|
|
62
|
+
// Wait for 10 seconds before sending
|
|
63
|
+
Thread.sleep(10000);
|
|
64
|
+
|
|
65
|
+
System.out.println("Sending message...");
|
|
66
|
+
|
|
67
|
+
String message = "This is Mohit calling...";
|
|
68
|
+
byte[] buffer = message.getBytes();
|
|
69
|
+
|
|
70
|
+
// Create datagram packet
|
|
71
|
+
DatagramPacket packet =
|
|
72
|
+
new DatagramPacket(buffer, buffer.length, group, PORT);
|
|
73
|
+
|
|
74
|
+
// Send packet
|
|
75
|
+
socket.send(packet);
|
|
76
|
+
|
|
77
|
+
System.out.println("Message sent successfully.");
|
|
78
|
+
|
|
79
|
+
socket.close();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
run javac *.java
|
|
83
|
+
java BroadcastClient
|
|
84
|
+
java BroadcastServer
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#prime no
|
|
2
|
+
#client
|
|
3
|
+
import java.net.*;
|
|
4
|
+
import java.io.*;
|
|
5
|
+
|
|
6
|
+
class ClientLine {
|
|
7
|
+
public static void main(String args[]) {
|
|
8
|
+
try {
|
|
9
|
+
// Create socket connection to localhost on port 8001
|
|
10
|
+
Socket s = new Socket("localhost", 8001);
|
|
11
|
+
|
|
12
|
+
// Read input from keyboard
|
|
13
|
+
BufferedReader br = new BufferedReader(
|
|
14
|
+
new InputStreamReader(System.in));
|
|
15
|
+
|
|
16
|
+
System.out.print("Enter number: ");
|
|
17
|
+
int a = Integer.parseInt(br.readLine());
|
|
18
|
+
|
|
19
|
+
// Send data to server
|
|
20
|
+
DataOutputStream out =
|
|
21
|
+
new DataOutputStream(s.getOutputStream());
|
|
22
|
+
out.writeInt(a);
|
|
23
|
+
|
|
24
|
+
// Receive data from server
|
|
25
|
+
DataInputStream in =
|
|
26
|
+
new DataInputStream(s.getInputStream());
|
|
27
|
+
System.out.println(in.readUTF());
|
|
28
|
+
|
|
29
|
+
// Close socket
|
|
30
|
+
s.close();
|
|
31
|
+
}
|
|
32
|
+
catch (Exception e) {
|
|
33
|
+
System.out.println(e.toString());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#server
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Folder highlights
|
|
42
|
+
Java programs implement a TCP client and server to check if an integer input is prime over port 8001.
|
|
43
|
+
|
|
44
|
+
import java.net.*;
|
|
45
|
+
import java.io.*;
|
|
46
|
+
|
|
47
|
+
class ServerLine {
|
|
48
|
+
|
|
49
|
+
public static void main(String args[]) {
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
// Create server socket at port 8001
|
|
53
|
+
ServerSocket ss = new ServerSocket(8001);
|
|
54
|
+
|
|
55
|
+
System.out.println("Server started... Waiting for client");
|
|
56
|
+
|
|
57
|
+
// Accept client connection
|
|
58
|
+
Socket s = ss.accept();
|
|
59
|
+
|
|
60
|
+
// Read number from client
|
|
61
|
+
DataInputStream in =
|
|
62
|
+
new DataInputStream(s.getInputStream());
|
|
63
|
+
|
|
64
|
+
int x = in.readInt();
|
|
65
|
+
|
|
66
|
+
// Send result back to client
|
|
67
|
+
DataOutputStream out =
|
|
68
|
+
new DataOutputStream(s.getOutputStream());
|
|
69
|
+
|
|
70
|
+
boolean isPrime = true;
|
|
71
|
+
|
|
72
|
+
if (x <= 1) {
|
|
73
|
+
isPrime = false;
|
|
74
|
+
} else {
|
|
75
|
+
for (int i = 2; i <= x / 2; i++) {
|
|
76
|
+
if (x % i == 0) {
|
|
77
|
+
isPrime = false;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (isPrime) {
|
|
84
|
+
out.writeUTF(x + " is prime");
|
|
85
|
+
} else {
|
|
86
|
+
out.writeUTF(x + " is not prime");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Close connection
|
|
90
|
+
s.close();
|
|
91
|
+
ss.close();
|
|
92
|
+
|
|
93
|
+
} catch (Exception e) {
|
|
94
|
+
System.out.println(e.toString());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: javac
|
|
3
|
+
Version: 1.1.5
|
|
4
|
+
Summary: Teri Maa ne bhoot ke sath suhagrat rachai thi woh bhoot huh mein
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: kya dekh rha hai luvday
|
|
7
|
+
Author-email: xyz@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: author-email
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: license
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: requires-python
|
|
21
|
+
Dynamic: summary
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
javac/__init__.py
|
|
5
|
+
javac/calculator.py
|
|
6
|
+
javac/chatting application.py
|
|
7
|
+
javac/current date and time.py
|
|
8
|
+
javac/even odd.py
|
|
9
|
+
javac/multicast socket.py
|
|
10
|
+
javac/prime no.py
|
|
11
|
+
javac.egg-info/PKG-INFO
|
|
12
|
+
javac.egg-info/SOURCES.txt
|
|
13
|
+
javac.egg-info/dependency_links.txt
|
|
14
|
+
javac.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
javac
|
javac-1.1.5/setup.cfg
ADDED
javac-1.1.5/setup.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
import io
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
def read(fname):
|
|
6
|
+
return io.open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8").read()
|
|
7
|
+
|
|
8
|
+
setup(
|
|
9
|
+
name="javac", # must be unique on PyPI
|
|
10
|
+
version="1.1.5",
|
|
11
|
+
author="kya dekh rha hai luvday",
|
|
12
|
+
author_email="xyz@gmail.com",
|
|
13
|
+
description="Teri Maa ne bhoot ke sath suhagrat rachai thi woh bhoot huh mein ",
|
|
14
|
+
long_description=read("README.md"),
|
|
15
|
+
long_description_content_type="text/markdown",
|
|
16
|
+
url="", # optional
|
|
17
|
+
packages=find_packages(),
|
|
18
|
+
include_package_data=True,
|
|
19
|
+
install_requires=[],
|
|
20
|
+
license="MIT", # ✅ SPDX-compliant license declaration
|
|
21
|
+
classifiers=[
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
],
|
|
25
|
+
python_requires=">=3.6",
|
|
26
|
+
)
|