cop3252 lamba expressions & networking

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

34 Terms

1
New cards

lambda calculus

the basis of functional programming languages

2
New cards

strategy pattern

passing a method into another method

3
New cards

lambda expressions

used with functional interfaces, replaces many uses of anonymous inner classes, and represents an anonymous method or function

4
New cards

lambda syntax

(parameters) → {statements}

5
New cards

void PrintHello() {

System.out.println(“Hello, World”); }

() → System.out.println(“Hello, World”)

6
New cards

double average (double x, double y, double z) { return(x+y+z)/3.0; }

(double x, double y, double z) → (x+y+z)/3.0

7
New cards

void UpdateIfOdd (int x) {

if (x%2≠0) {

y=10;

System.out.print(“y is now “ +y); }

x → { if (x%2≠0) y=10; System.out.print(“y is now “ +y); }

8
New cards

cilent

requests some information or action

9
New cards

server

performs action and responds to the cilent

10
New cards

connection-based service

a cilent and server form a connection and communicate back and forth until the connection is given up

11
New cards

connectionless service

a cilent and server communicate by sending individual packets back and forth

12
New cards

socket

a software construct that represents 1 endpoint of a connection

13
New cards

contains Java’s fundamental networking capabilities

package.java.net

14
New cards

URL stands for

uniform resource locator

15
New cards

class for wrapping up a URL and working with it (contains many get methods)

java.net.URL

16
New cards

stream sockets

TCP communication, used for connection-oriented communcation between a cilent and server 

17
New cards

datagram sockets

UDP communication, used for connectionless communcation between programs 

18
New cards

UDP

user datagram protocol, most common protocol for connectionless communication

19
New cards

TCP

transmission control protocol, most common protocol for connection-based transmission

20
New cards

SSH is

connection-oriented

21
New cards

port number

identifies the application on the host computer

22
New cards

queue length

max number of cilents that can connect to server

23
New cards

Server: create a ServerSocket object

ServerSocket serv=new ServerSocket (portNumber, queueLength);

24
New cards

Server: listen for a cilent connection

Socket connection=serv.accept();

25
New cards

Server: close the socket

connection.close();

26
New cards

Server: input and output streams

OutputStream os = connection.getOutputStream();

InputStream is = connection.getInputStream();

27
New cards

Cilent: create a socket to connect to the server

Socket connection = new Socket (serverAddress, port);

28
New cards

class DatagramSocket

used for creation of datagram sockets

29
New cards

creation of datagram sockets

DatagramSocket s1, s2;

s1 = new DatagramSocket(12345); // bind to port 12345

s2 = new DatagramSocket(); // bind to any available port on local host machine

30
New cards

class DatagramPacket

used to build packets of information to send over datagram sockets

31
New cards

create a packet for storing up to 500 bytes of data that will be used to receive a datagram packet

DatagramPacket p1, p2;

byte[] data1=new byte[500]; 

p1=new DatagramPacket(data1, data1.length);

32
New cards

send a packet

s2.send(p2);

33
New cards

receive a datagram packet

s1.receive(p1);

34
New cards

convert a string to a byte array and create a datagram packet of outgoing data (“Hello, World”), set the port number to 1234

String message=”Hello, World”;

byte[] data2=message.getBytes();

p2 = new DatagramPacket (data2, data2.length, InetAddress.getLocalHost(), 1234);